<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.5">
<meta name="author" content="2019-08-08 13:15:33 CEST">
<title>N4JS Language Specification</title>
<link rel="stylesheet" href="styles/spec.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<!-- ************* docinfo ******************************************************************* -->


<!-- ************* Favicon ************-->
<link rel="icon" href="images/favicon.ico" />

<!-- ************* Back-to-top JQuery ************* -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>


<link href="styles/prism.min.css" rel="stylesheet" />
<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

<!-- ************* Styles ************* -->
<link rel="stylesheet" type="text/css" href="styles/n4jsspec-adoc.css">


<!-- ****************** NavBar ****************** -->
<div id="menubar">
	<div class="banner">
        <a href="https://www.eclipse.org/n4js/#"><img id="logo" src="images/n4js-logo.png" alt="Eclipse N4JS"></a>
    </div>
<ul>
  <li><a href="index.html">Index</a></li>
</ul>
</div>
<!-- ************* docinfo ******************************************************************* -->
<style>
      .admonitionblock td.icon .icon-todo:before{content:"\f249";color:#f4ee42}
    </style>
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>N4JS Language Specification</h1>
<div class="details">
<span id="author" class="author">2019-08-08 13:15:33 CEST</span><br>
<span id="revnumber">version 0.9</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="introduction.html#_introduction">1. Introduction</a>
<ul class="sectlevel2">
<li><a href="introduction.html#_notation">1.1. Notation</a>
<ul class="sectlevel3">
<li><a href="introduction.html#_grammar-notation">1.1.1. Grammar Notation</a></li>
<li><a href="introduction.html#_type-judgments-and-rules-and-constraints-notation">1.1.2. Type Judgments and Rules and Constraints Notation</a>
<ul class="sectlevel4">
<li><a href="introduction.html#_typing-rules-and-judgments">1.1.2.1. Typing Rules and Judgments</a></li>
<li><a href="introduction.html#_types-of-an-element">1.1.2.2. Types of an Element</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="introduction.html#_auxiliary-functions">1.2. Auxiliary Functions</a>
<ul class="sectlevel3">
<li><a href="introduction.html#_binding">1.2.1. Binding</a></li>
<li><a href="introduction.html#_merging-types">1.2.2. Merging Types</a>
<ul class="sectlevel4">
<li><a href="introduction.html#_logic-formulas">1.2.2.1. Logic Formulas</a></li>
</ul>
</li>
<li><a href="introduction.html#_symbols-and-font-convention">1.2.3. Symbols and Font Convention</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="grammar.html#_grammar">2. Grammar</a>
<ul class="sectlevel2">
<li><a href="grammar.html#_lexical-conventions">2.1. Lexical Conventions</a>
<ul class="sectlevel3">
<li><a href="grammar.html#_identifier-names-and-identifiers">2.1.1. Identifier Names and Identifiers</a></li>
<li><a href="grammar.html#_this-keyword">2.1.2. This Keyword</a></li>
<li><a href="grammar.html#_regular-expression-literals">2.1.3. Regular Expression Literals</a></li>
<li><a href="grammar.html#_automatic-semicolon-insertion">2.1.4. Automatic Semicolon Insertion</a></li>
<li><a href="grammar.html#_jsdoc">2.1.5. JSDoc</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="names.html#_names">3. Names</a>
<ul class="sectlevel2">
<li><a href="names.html#_access-control">3.1. Access Control</a></li>
<li><a href="names.html#_accessibility-of-types-top-level-variables-and-function-declarations">3.2. Accessibility of Types, Top-Level Variables and Function Declarations</a>
<ul class="sectlevel3">
<li><a href="names.html#_accessibility-of-members">3.2.1. Accessibility of Members</a></li>
<li><a href="names.html#_valid-names">3.2.2. Valid Names</a></li>
<li><a href="names.html#_qualified-names">3.2.3. Qualified Names</a></li>
<li><a href="names.html#_name-duplicates">3.2.4. Name Duplicates</a>
<ul class="sectlevel4">
<li><a href="names.html#_lexical-environment">3.2.4.1. Lexical Environment</a></li>
<li><a href="names.html#_duplicates-and-shadowing">3.2.4.2. Duplicates and Shadowing</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_types">4. Types</a>
<ul class="sectlevel2">
<li><a href="types.html#_overview">4.1. Overview</a></li>
<li><a href="types.html#_type-expressions">4.2. Type Expressions</a>
<ul class="sectlevel3">
<li><a href="types.html#_syntax">4.2.1. Syntax</a></li>
<li><a href="types.html#_properties">4.2.2. Properties</a></li>
<li><a href="types.html#_semantics">4.2.3. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_type-inference">4.3. Type Inference</a></li>
<li><a href="types.html#_generic-and-parameterized-types">4.4. Generic and Parameterized Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_generic-types">4.4.1. Generic Types</a></li>
<li><a href="types.html#_type-variables">4.4.2. Type Variables</a></li>
<li><a href="types.html#_parameterized-types">4.4.3. Parameterized Types</a></li>
</ul>
</li>
<li><a href="types.html#_primitive-ecmascript-types">4.5. Primitive ECMAScript Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_undefined-type">4.5.1. Undefined Type</a></li>
<li><a href="types.html#_null-type">4.5.2. Null Type</a></li>
<li><a href="types.html#_primitive-boolean-type">4.5.3. Primitive Boolean Type</a></li>
<li><a href="types.html#_primitive-string-type">4.5.4. Primitive String Type</a></li>
<li><a href="types.html#_primitive-number-type">4.5.5. Primitive Number Type</a></li>
<li><a href="types.html#_primitive-type-int">4.5.6. Primitive Type int</a></li>
<li><a href="types.html#_primitive-symbol-type">4.5.7. Primitive Symbol Type</a></li>
</ul>
</li>
<li><a href="types.html#_primitive-n4js-types">4.6. Primitive N4JS Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_any-type">4.6.1. Any Type</a>
<ul class="sectlevel4">
<li><a href="types.html#any-type-semantics">4.6.1.1. Semantics</a></li>
<li><a href="types.html#any-type-type-inference">4.6.1.2. Type Inference</a>
<ul class="sectlevel5">
<li><a href="types.html#_default-type-of-variables">4.6.1.2.1. Default Type of Variables</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_void-type">4.6.2. Void Type</a>
<ul class="sectlevel4">
<li><a href="types.html#void-type-semantics">4.6.2.1. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_unknown-type">4.6.3. Unknown Type</a></li>
<li><a href="types.html#_primitive-pathselector-and-i18nkey">4.6.4. Primitive Pathselector and I18nKey</a>
<ul class="sectlevel4">
<li><a href="types.html#pathselector-semantics">4.6.4.1. Semantics</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_built-in-ecmascript-object-types">4.7. Built-in ECMAScript Object Types</a>
<ul class="sectlevel3">
<li><a href="types.html#ECMAScript-objects-semantics">4.7.1. Semantics</a></li>
<li><a href="types.html#_object-type">4.7.2. Object Type</a></li>
<li><a href="types.html#_function-object-type">4.7.3. Function-Object-Type</a></li>
<li><a href="types.html#_array-object-type">4.7.4. Array Object Type</a></li>
<li><a href="types.html#_string-object-type">4.7.5. String Object Type</a></li>
<li><a href="types.html#_boolean-object-type">4.7.6. Boolean Object Type</a></li>
<li><a href="types.html#_number-object-type">4.7.7. Number Object Type</a></li>
<li><a href="types.html#_global-object-type">4.7.8. Global Object Type</a></li>
<li><a href="types.html#_symbol">4.7.9. Symbol</a></li>
<li><a href="types.html#_promise">4.7.10. Promise</a></li>
<li><a href="types.html#_iterator-interface">4.7.11. Iterator Interface</a></li>
<li><a href="types.html#_iterable-interface">4.7.12. Iterable Interface</a></li>
</ul>
</li>
<li><a href="types.html#_built-in-n4js-types">4.8. Built-In N4JS Types</a>
<ul class="sectlevel3">
<li><a href="types.html#_n4object">4.8.1. N4Object</a>
<ul class="sectlevel4">
<li><a href="types.html#N4Object-semantics">4.8.1.1. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_n4class">4.8.2. N4Class</a></li>
<li><a href="types.html#IterableN">4.8.3. IterableN</a></li>
</ul>
</li>
<li><a href="types.html#_type-modifiers">4.9. Type Modifiers</a>
<ul class="sectlevel3">
<li><a href="types.html#Type_Modifiers_Dynamic">4.9.1. Dynamic</a></li>
<li><a href="types.html#_optional-return-types">4.9.2. Optional Return Types</a></li>
</ul>
</li>
<li><a href="types.html#_union-and-intersection-type-composed-types">4.10. Union and Intersection Type (Composed Types)</a>
<ul class="sectlevel3">
<li><a href="types.html#_union-type">4.10.1. Union Type</a>
<ul class="sectlevel4">
<li><a href="types.html#union-type-syntax">4.10.1.1. Syntax</a></li>
<li><a href="types.html#union-type-semantics">4.10.1.2. Semantics</a></li>
<li><a href="types.html#_warnings">4.10.1.3. Warnings</a></li>
</ul>
</li>
<li><a href="types.html#_intersection-type">4.10.2. Intersection Type</a>
<ul class="sectlevel4">
<li><a href="types.html#intersection-type-syntax">4.10.2.1. Syntax</a></li>
<li><a href="types.html#intersection-type-semantics">4.10.2.2. Semantics</a></li>
<li><a href="types.html#_warnings-2">4.10.2.3. Warnings</a></li>
</ul>
</li>
<li><a href="types.html#_composed-types-in-wildcards">4.10.3. Composed Types in Wildcards</a></li>
<li><a href="types.html#_property-access-for-composed-types">4.10.4. Property Access for Composed Types</a>
<ul class="sectlevel4">
<li><a href="types.html#_properties-of-union-type">4.10.4.1. Properties of Union Type</a>
<ul class="sectlevel5">
<li><a href="types.html#_remarks-on-union-type-s-members">4.10.4.1.1. Remarks on union type’s members:</a></li>
</ul>
</li>
<li><a href="types.html#_properties-of-intersection-type">4.10.4.2. Properties of Intersection Type</a>
<ul class="sectlevel5">
<li><a href="types.html#_remarks-on-intersection-type-s-methods">4.10.4.2.1. Remarks on intersection type’s methods:</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="types.html#_constructor-and-classifier-type">4.11. Constructor and Classifier Type</a>
<ul class="sectlevel3">
<li><a href="types.html#_syntax-3">4.11.1. Syntax</a></li>
<li><a href="types.html#_semantics-2">4.11.2. Semantics</a></li>
<li><a href="types.html#_constructors-and-prototypes-in-ecmascript-2015">4.11.3. Constructors and Prototypes in ECMAScript 2015</a></li>
</ul>
</li>
<li><a href="types.html#_this-type">4.12. This Type</a>
<ul class="sectlevel3">
<li><a href="types.html#this-type-syntax">4.12.1. Syntax</a></li>
<li><a href="types.html#this-keyword-semantics">4.12.2. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_enums">4.13. Enums</a>
<ul class="sectlevel3">
<li><a href="types.html#_enums-n4js">4.13.1. Enums (N4JS)</a>
<ul class="sectlevel4">
<li><a href="types.html#enums-syntax">4.13.1.1. Syntax</a></li>
<li><a href="types.html#enums-semantics">4.13.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="types.html#_string-based-enums">4.13.2. String-Based Enums</a></li>
</ul>
</li>
<li><a href="types.html#_short-hand-syntax">4.14. Short-Hand Syntax</a>
<ul class="sectlevel3">
<li><a href="types.html#_array-short-hand-syntax">4.14.1. Array Short-Hand Syntax</a></li>
<li><a href="types.html#_iterablen-short-hand-syntax">4.14.2. IterableN Short-Hand Syntax</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_classifiers">5. Classifiers</a>
<ul class="sectlevel2">
<li><a href="classifiers.html#_n4js-specific-classifiers">5.1. N4JS Specific Classifiers</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_properties-2">5.1.1. Properties</a></li>
<li><a href="classifiers.html#_common-semantics-of-classifiers">5.1.2. Common Semantics of Classifiers</a></li>
<li><a href="classifiers.html#_classes">5.1.3. Classes</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_definition-of-classes">5.1.3.1. Definition of Classes</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#class-syntax">5.1.3.1.1. Syntax</a></li>
<li><a href="classifiers.html#class-properties">5.1.3.1.2. Properties</a></li>
<li><a href="classifiers.html#class-type-inference">5.1.3.1.3. Type Inference</a></li>
</ul>
</li>
<li><a href="classifiers.html#class-semantics">5.1.3.2. Semantics</a></li>
<li><a href="classifiers.html#_final-modifier">5.1.3.3. Final Modifier</a></li>
<li><a href="classifiers.html#_abstract-classes">5.1.3.4. Abstract Classes</a></li>
<li><a href="classifiers.html#_non-instantiable-classes">5.1.3.5. Non-Instantiable Classes</a></li>
<li><a href="classifiers.html#_superclass">5.1.3.6. Superclass</a></li>
</ul>
</li>
<li><a href="classifiers.html#_interfaces">5.1.4. Interfaces</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_definition-of-interfaces">5.1.4.1. Definition of Interfaces</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#interfaces-syntax">5.1.4.1.1. Syntax</a></li>
<li><a href="classifiers.html#interfaces-properties">5.1.4.1.2. Properties</a></li>
<li><a href="classifiers.html#interfaces-type-inference">5.1.4.1.3. Type Inference</a></li>
<li><a href="classifiers.html#interfaces-semantics">5.1.4.1.4. Semantics</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_generic-classifiers">5.1.5. Generic Classifiers</a></li>
<li><a href="classifiers.html#sec:definition-site-variance">5.1.6. Definition-Site Variance</a></li>
</ul>
</li>
<li><a href="classifiers.html#_members">5.2. Members</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_syntax-4">5.2.1. Syntax</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_properties-3">5.2.1.1. Properties</a></li>
</ul>
</li>
<li><a href="classifiers.html#_semantics-3">5.2.2. Semantics</a></li>
<li><a href="classifiers.html#_methods">5.2.3. Methods</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_syntax-5">5.2.3.1. Syntax</a></li>
<li><a href="classifiers.html#_properties-4">5.2.3.2. Properties</a></li>
<li><a href="classifiers.html#_semantics-4">5.2.3.3. Semantics</a></li>
<li><a href="classifiers.html#_final-methods">5.2.3.4. Final Methods</a></li>
<li><a href="classifiers.html#_abstract-methods">5.2.3.5. Abstract Methods</a></li>
<li><a href="classifiers.html#_generic-methods">5.2.3.6. Generic Methods</a></li>
</ul>
</li>
<li><a href="classifiers.html#_default-methods-in-interfaces">5.2.4. Default Methods in Interfaces</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_asynchronous-methods">5.2.4.1. Asynchronous Methods</a></li>
</ul>
</li>
<li><a href="classifiers.html#_constructors">5.2.5. Constructors</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_structural-this-type-in-constructor">5.2.5.1. Structural This Type in Constructor</a></li>
<li><a href="classifiers.html#spec-constructor">5.2.5.2. @Spec Constructor</a></li>
<li><a href="classifiers.html#_callable-constructors">5.2.5.3. Callable Constructors</a></li>
<li><a href="classifiers.html#_covariant-constructors">5.2.5.4. Covariant Constructors</a></li>
</ul>
</li>
<li><a href="classifiers.html#_data-fields">5.2.6. Data Fields</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#data-fields-syntax">5.2.6.1. Syntax</a></li>
<li><a href="classifiers.html#data-fields-properties">5.2.6.2. Properties</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#data-fields-semantics">5.2.6.2.1. Semantics</a></li>
<li><a href="classifiers.html#data-fields-type-inference">5.2.6.2.2. Type Inference</a></li>
</ul>
</li>
<li><a href="classifiers.html#_assignment-modifiers">5.2.6.3. Assignment Modifiers</a></li>
<li><a href="classifiers.html#_field-accessors-getter-setter">5.2.6.4. Field Accessors (Getter/Setter)</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#field-acessors-syntax">5.2.6.4.1. Syntax</a></li>
<li><a href="classifiers.html#field-acessors-properties">5.2.6.4.2. Properties</a></li>
<li><a href="classifiers.html#field-accessors-semantics">5.2.6.4.3. Semantics</a></li>
</ul>
</li>
<li><a href="classifiers.html#optional-fields">5.2.6.5. Optional Fields</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_syntax-6">5.2.6.5.1. Syntax</a></li>
<li><a href="classifiers.html#_semantics-5">5.2.6.5.2. Semantics</a></li>
<li><a href="classifiers.html#_background">5.2.6.5.3. Background</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_static-members">5.2.7. Static Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_access-from-and-to-static-members">5.2.7.1. Access From and To Static Members</a></li>
<li><a href="classifiers.html#_generic-static-methods">5.2.7.2. Generic static methods</a></li>
<li><a href="classifiers.html#_static-members-of-interfaces">5.2.7.3. Static Members of Interfaces</a></li>
</ul>
</li>
<li><a href="classifiers.html#_redefinition-of-members">5.2.8. Redefinition of Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_overriding-of-members">5.2.8.1. Overriding of Members</a></li>
<li><a href="classifiers.html#_implementation-of-members">5.2.8.2. Implementation of Members</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_member-consumption">5.2.8.2.1. Member Consumption</a></li>
<li><a href="classifiers.html#_member-implementation">5.2.8.2.2. Member Implementation</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="classifiers.html#_structural-typing">5.3. Structural Typing</a>
<ul class="sectlevel3">
<li><a href="classifiers.html#_syntax-7">5.3.1. Syntax</a></li>
<li><a href="classifiers.html#_definition-site-structural-typing">5.3.2. Definition Site Structural Typing</a></li>
<li><a href="classifiers.html#_use-site-structural-typing">5.3.3. Use-Site Structural Typing</a></li>
<li><a href="classifiers.html#structural-readWriteInit-field-typing">5.3.4. Structural Read-only, Write-only and Initializer Field Typing</a></li>
<li><a href="classifiers.html#_public-setter-annotated-with-code-providesinitializer-code">5.3.5. Public Setter Annotated With <code>ProvidesInitializer</code></a></li>
<li><a href="classifiers.html#_structural-types-with-optional-fields">5.3.6. Structural Types With Optional Fields</a></li>
<li><a href="classifiers.html#_structural-types-with-access-modifier">5.3.7. Structural Types With Access Modifier</a></li>
<li><a href="classifiers.html#_structural-types-with-additional-members">5.3.8. Structural Types With Additional Members</a>
<ul class="sectlevel4">
<li><a href="classifiers.html#_syntax-8">5.3.8.1. Syntax</a>
<ul class="sectlevel5">
<li><a href="classifiers.html#_semantics-6">5.3.8.1.1. Semantics</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_functions">6. Functions</a>
<ul class="sectlevel2">
<li><a href="functions.html#_function-type">6.1. Function Type</a>
<ul class="sectlevel3">
<li><a href="functions.html#_properties-5">6.1.1. Properties</a></li>
<li><a href="functions.html#function-type-inference">6.1.2. Type Inference</a></li>
<li><a href="functions.html#_autoboxing-of-function-type">6.1.3. Autoboxing of Function Type</a></li>
<li><a href="functions.html#_arguments-object">6.1.4. Arguments Object</a></li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-5-function-definition">6.2. ECMAScript 5 Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_function-declaration">6.2.1. Function Declaration</a>
<ul class="sectlevel4">
<li><a href="functions.html#_syntax-9">6.2.1.1. Syntax</a></li>
<li><a href="functions.html#_semantics-8">6.2.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="functions.html#_function-expression">6.2.2. Function Expression</a>
<ul class="sectlevel4">
<li><a href="functions.html#function-expression-syntax">6.2.2.1. Syntax</a></li>
<li><a href="functions.html#_semantics-and-type-inference">6.2.2.2. Semantics and Type Inference</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-2015-function-definition">6.3. ECMAScript 2015 Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_formal-parameters">6.3.1. Formal Parameters</a>
<ul class="sectlevel4">
<li><a href="functions.html#Type_Modifiers_Optional">6.3.1.1. Optional Parameters</a></li>
<li><a href="functions.html#Type_Modifiers_Default">6.3.1.2. Default Parameters</a></li>
<li><a href="functions.html#Type_Modifiers_Variadic">6.3.1.3. Variadic</a></li>
</ul>
</li>
<li><a href="functions.html#_generator-functions">6.3.2. Generator Functions</a>
<ul class="sectlevel4">
<li><a href="functions.html#generator-functions-syntax">6.3.2.1. Syntax</a></li>
<li><a href="functions.html#generator-functions-semantics">6.3.2.2. Semantics</a></li>
<li><a href="functions.html#_generator-arrow-functions">6.3.2.3. Generator Arrow Functions</a></li>
</ul>
</li>
<li><a href="functions.html#_arrow-function-expression">6.3.3. Arrow Function Expression</a>
<ul class="sectlevel4">
<li><a href="functions.html#arrow-function-expression-syntax">6.3.3.1. Syntax</a></li>
<li><a href="functions.html#arrow-function-expression-semantics-and-type-inference">6.3.3.2. Semantics and Type Inference</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_ecmascript-proposals-function-definition">6.4. ECMAScript Proposals Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_asynchronous-functions">6.4.1. Asynchronous Functions</a>
<ul class="sectlevel4">
<li><a href="functions.html#asynchronous-functions-syntax">6.4.1.1. Syntax</a></li>
<li><a href="functions.html#asynchronous-functions-semantics">6.4.1.2. Semantics</a></li>
<li><a href="functions.html#_asynchronous-arrow-functions">6.4.1.3. Asynchronous Arrow Functions</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="functions.html#_n4js-extended-function-definition">6.5. N4JS Extended Function Definition</a>
<ul class="sectlevel3">
<li><a href="functions.html#_generic-functions">6.5.1. Generic Functions</a></li>
<li><a href="functions.html#_promisifiable-functions">6.5.2. Promisifiable Functions</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_conversions-and-reflection">7. Conversions and Reflection</a>
<ul class="sectlevel2">
<li><a href="conversions_and_reflection.html#_autoboxing-and-coercing">7.1. Autoboxing and Coercing</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_coercing">7.1.1. Coercing</a></li>
<li><a href="conversions_and_reflection.html#_autoboxing-of-primitives">7.1.2. Autoboxing of Primitives</a></li>
<li><a href="conversions_and_reflection.html#_autoboxing-of-function-expressions-and-declarations">7.1.3. Autoboxing of Function Expressions and Declarations</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_auto-conversion-of-objects">7.2. Auto-Conversion of Objects</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_auto-conversion-of-class-instances">7.2.1. Auto-Conversion of Class Instances</a>
<ul class="sectlevel4">
<li><a href="conversions_and_reflection.html#_auto-conversion-of-interface-instances">7.2.1.1. Auto-Conversion of Interface Instances</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_auto-conversion-of-enum-literals">7.2.2. Auto-Conversion of Enum Literals</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_type-cast-and-type-check">7.3. Type Cast and Type Check</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_type-cast">7.3.1. Type Cast</a></li>
<li><a href="conversions_and_reflection.html#_type-check">7.3.2. Type Check</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_reflection-meta-information">7.4. Reflection meta-information</a>
<ul class="sectlevel3">
<li><a href="conversions_and_reflection.html#_reflection-for-classes">7.4.1. Reflection for Classes</a></li>
<li><a href="conversions_and_reflection.html#_reflection-for-interfaces">7.4.2. Reflection for Interfaces</a></li>
<li><a href="conversions_and_reflection.html#_reflection-for-enumerations">7.4.3. Reflection for Enumerations</a></li>
</ul>
</li>
<li><a href="conversions_and_reflection.html#_conversion-of-primitive-types">7.5. Conversion of primitive types</a></li>
</ul>
</li>
<li><a href="#_expressions">8. Expressions</a>
<ul class="sectlevel2">
<li><a href="#_ecmascript-5-expressions">8.1. ECMAScript 5 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_the-this-literal">8.1.1. The this Literal</a></li>
<li><a href="#_identifier">8.1.2. Identifier</a></li>
<li><a href="#_literals">8.1.3. Literals</a>
<ul class="sectlevel4">
<li><a href="#_integer-literals">8.1.3.1. Integer Literals</a></li>
</ul>
</li>
<li><a href="#_array-literal">8.1.4. Array Literal</a></li>
<li><a href="#_object-literal">8.1.5. Object Literal</a>
<ul class="sectlevel4">
<li><a href="#_properties-6">8.1.5.1. Properties</a></li>
<li><a href="#_scoping-and-linking">8.1.5.2. Scoping and linking</a></li>
</ul>
</li>
<li><a href="#_parenthesized-expression-and-grouping-operator">8.1.6. Parenthesized Expression and Grouping Operator</a></li>
<li><a href="#_property-accessors">8.1.7. Property Accessors</a>
<ul class="sectlevel4">
<li><a href="#properties-1">8.1.7.1. Properties</a></li>
</ul>
</li>
<li><a href="#_new-expression">8.1.8. New Expression</a></li>
<li><a href="#_function-expression-2">8.1.9. Function Expression</a></li>
<li><a href="#_function-calls">8.1.10. Function Calls</a></li>
<li><a href="#_postfix-expression">8.1.11. Postfix Expression</a></li>
<li><a href="#_unary-expression">8.1.12. Unary Expression</a></li>
<li><a href="#_multiplicative-expression">8.1.13. Multiplicative Expression</a></li>
<li><a href="#_additive-expression">8.1.14. Additive Expression</a>
<ul class="sectlevel4">
<li><a href="#type-inference-10">8.1.14.1. Type Inference</a></li>
</ul>
</li>
<li><a href="#_bitwise-shift-expression">8.1.15. Bitwise Shift Expression</a></li>
<li><a href="#_relational-expression">8.1.16. Relational Expression</a></li>
<li><a href="#_equality-expression">8.1.17. Equality Expression</a></li>
<li><a href="#_binary-bitwise-expression">8.1.18. Binary Bitwise Expression</a></li>
<li><a href="#_binary-logical-expression">8.1.19. Binary Logical Expression</a></li>
<li><a href="#_conditional-expression">8.1.20. Conditional Expression</a></li>
<li><a href="#_assignment-expression">8.1.21. Assignment Expression</a></li>
<li><a href="#_comma-expression">8.1.22. Comma Expression</a></li>
</ul>
</li>
<li><a href="#_ecmascript-6-expressions">8.2. ECMAScript 6 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_the-super-keyword">8.2.1. The super Keyword</a></li>
</ul>
</li>
<li><a href="#_ecmascript-7-expressions">8.3. ECMAScript 7 Expressions</a>
<ul class="sectlevel3">
<li><a href="#_await-expression">8.3.1. Await Expression</a></li>
</ul>
</li>
<li><a href="#_n4js-specific-expressions">8.4. N4JS Specific Expressions</a>
<ul class="sectlevel3">
<li><a href="#_class-expression">8.4.1. Class Expression</a></li>
<li><a href="#_cast-as-expression">8.4.2. Cast (As) Expression</a>
<ul class="sectlevel4">
<li><a href="#cast-as-expression-semantics-type-inference">8.4.2.1. Semantics and Type Inference</a></li>
</ul>
</li>
<li><a href="#Import_Calls">8.4.3. Import Calls</a></li>
</ul>
</li>
<li><a href="#compile-time-expressions">8.5. Compile-Time Expressions</a></li>
</ul>
</li>
<li><a href="statements.html#_statements">9. Statements</a>
<ul class="sectlevel2">
<li><a href="statements.html#_ecmascript-5-statements">9.1. ECMAScript 5 Statements</a>
<ul class="sectlevel3">
<li><a href="statements.html#_function-or-field-accessor-bodies">9.1.1. Function or Field Accessor Bodies</a></li>
<li><a href="statements.html#_variable-statement">9.1.2. Variable Statement</a></li>
<li><a href="statements.html#_if-statement">9.1.3. If Statement</a></li>
<li><a href="statements.html#_iteration-statements">9.1.4. Iteration Statements</a></li>
<li><a href="statements.html#_return-statement">9.1.5. Return Statement</a></li>
<li><a href="statements.html#_with-statement">9.1.6. With Statement</a></li>
<li><a href="statements.html#_switch-statement">9.1.7. Switch Statement</a></li>
<li><a href="statements.html#_throw-try-and-catch-statements">9.1.8. Throw, Try, and Catch Statements</a></li>
<li><a href="statements.html#_debugger-statement">9.1.9. Debugger Statement</a></li>
</ul>
</li>
<li><a href="statements.html#_ecmascript-6-statements">9.2. ECMAScript 6 Statements</a>
<ul class="sectlevel3">
<li><a href="statements.html#_let">9.2.1. Let</a></li>
<li><a href="statements.html#_const">9.2.2. Const</a></li>
<li><a href="statements.html#_for-of-statement">9.2.3. <code>for &#8230;&#8203; of</code> statement</a></li>
<li><a href="statements.html#_import-statement">9.2.4. Import Statement</a>
<ul class="sectlevel4">
<li><a href="statements.html#Dynamic_Imports">9.2.4.1. Dynamic Imports</a></li>
<li><a href="statements.html#_immutabilaty-of-imports">9.2.4.2. Immutabilaty of Imports</a></li>
</ul>
</li>
<li><a href="statements.html#_export-statement">9.2.5. Export Statement</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="annotations.html#_annotations">10. Annotations</a>
<ul class="sectlevel2">
<li><a href="annotations.html#_introduction-2">10.1. Introduction</a>
<ul class="sectlevel3">
<li><a href="annotations.html#_syntax-13">10.1.1. Syntax</a></li>
<li><a href="annotations.html#_properties-7">10.1.2. Properties</a></li>
<li><a href="annotations.html#_element-specific-annotations">10.1.3. Element-Specific Annotations</a></li>
<li><a href="annotations.html#_general-annotations">10.1.4. General Annotations</a>
<ul class="sectlevel4">
<li><a href="annotations.html#_idebug">10.1.4.1. IDEBUG</a></li>
</ul>
</li>
<li><a href="annotations.html#idebug-syntax">10.1.5. Syntax</a>
<ul class="sectlevel4">
<li><a href="annotations.html#_semantics-11">10.1.5.1. Semantics</a></li>
<li><a href="annotations.html#_suppress-warnings">10.1.5.2. Suppress Warnings</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="annotations.html#_declaration-of-annotations">10.2. Declaration of Annotations</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_extended-fetaures">11. Extended Fetaures</a>
<ul class="sectlevel2">
<li><a href="extended_fetaures.html#_array-and-object-destructuring">11.1. Array and Object Destructuring</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_syntax-14">11.1.1. Syntax</a></li>
<li><a href="extended_fetaures.html#_semantics-12">11.1.2. Semantics</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_dependency-injection">11.2. Dependency Injection</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_di-components-and-injectors">11.2.1. DI Components and Injectors</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_dicomponent-relations">11.2.1.1. DIComponent Relations</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_binders-and-bindings">11.2.2. Binders and Bindings</a></li>
<li><a href="extended_fetaures.html#_injection-points">11.2.3. Injection Points</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_field-injection">11.2.3.1. Field Injection</a></li>
<li><a href="extended_fetaures.html#_constructor-injection">11.2.3.2. Constructor Injection</a></li>
<li><a href="extended_fetaures.html#_method-injection">11.2.3.3. Method Injection</a>
<ul class="sectlevel5">
<li><a href="extended_fetaures.html#_provider">11.2.3.3.1. Provider</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="extended_fetaures.html#_n4js-di-life-cycle-and-scopes">11.2.4. N4JS DI Life Cycle and Scopes</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_injection-cylces">11.2.4.1. Injection Cylces</a></li>
<li><a href="extended_fetaures.html#_default-scope">11.2.4.2. Default Scope</a></li>
<li><a href="extended_fetaures.html#_singleton-scope">11.2.4.3. Singleton Scope</a></li>
<li><a href="extended_fetaures.html#_per-injection-chain-singleton">11.2.4.4. Per Injection Chain Singleton</a></li>
</ul>
</li>
<li><a href="extended_fetaures.html#_validation-of-callsites-targeting-n4injector-methods">11.2.5. Validation of callsites targeting N4Injector methods</a></li>
<li><a href="extended_fetaures.html#_n4js-di-annotations">11.2.6. N4JS DI Annotations</a>
<ul class="sectlevel4">
<li><a href="extended_fetaures.html#_n4js-di-generateinjector">11.2.6.1. N4JS DI @GenerateInjector</a></li>
<li><a href="extended_fetaures.html#_n4js-di-withparentinjector">11.2.6.2. N4JS DI @WithParentInjector</a></li>
<li><a href="extended_fetaures.html#_n4js-di-usebinder">11.2.6.3. N4JS DI @UseBinder</a></li>
<li><a href="extended_fetaures.html#_n4js-di-binder">11.2.6.4. N4JS DI @Binder</a></li>
<li><a href="extended_fetaures.html#_n4js-di-bind">11.2.6.5. N4JS DI @Bind</a></li>
<li><a href="extended_fetaures.html#_n4js-di-provides">11.2.6.6. N4JS DI @Provides</a></li>
<li><a href="extended_fetaures.html#_n4js-di-inject">11.2.6.7. N4JS DI @Inject</a></li>
<li><a href="extended_fetaures.html#_n4js-di-singleton">11.2.6.8. N4JS DI @Singleton</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="extended_fetaures.html#_test-support">11.3. Test Support</a></li>
<li><a href="extended_fetaures.html#_polyfill-definitions">11.4. Polyfill Definitions</a>
<ul class="sectlevel3">
<li><a href="extended_fetaures.html#_runtime-polyfill-definitions">11.4.1. Runtime Polyfill Definitions</a></li>
<li><a href="extended_fetaures.html#_static-polyfill-definitions">11.4.2. Static Polyfill Definitions</a></li>
<li><a href="extended_fetaures.html#_transpiling-static-polyfilled-classes">11.4.3. Transpiling static polyfilled classes</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="components.html#_components">12. Components</a>
<ul class="sectlevel2">
<li><a href="components.html#_overview-2">12.1. Overview</a></li>
<li><a href="components.html#Component_Types">12.2. Component Types</a>
<ul class="sectlevel3">
<li><a href="components.html#_libraries">12.2.1. Libraries</a></li>
<li><a href="components.html#_runtime-environment-and-runtime-libraries">12.2.2. Runtime Environment and Runtime Libraries</a></li>
<li><a href="components.html#_tests">12.2.3. Tests</a></li>
<li><a href="components.html#_type-definitions">12.2.4. Type Definitions</a></li>
</ul>
</li>
<li><a href="components.html#package-json">12.3. Package.json File</a>
<ul class="sectlevel3">
<li><a href="components.html#_basic-properties">12.3.1. Basic Properties</a></li>
<li><a href="components.html#_n4js-properties">12.3.2. N4JS Properties</a></li>
<li><a href="components.html#_constraints">12.3.3. Constraints</a></li>
</ul>
</li>
<li><a href="components.html#_support-for-npm-scopes">12.4. Support for NPM Scopes</a></li>
<li><a href="components.html#sec:N4JS-Type-Definitions">12.5. N4JS Type Definitions</a>
<ul class="sectlevel3">
<li><a href="components.html#_specify-type-definition">12.5.1. Specify Type Definition</a></li>
<li><a href="components.html#_name-conventions">12.5.2. Name Conventions</a></li>
<li><a href="components.html#_version-conventions">12.5.3. Version Conventions</a>
<ul class="sectlevel4">
<li><a href="components.html#_define-a-new-type-definition-package">12.5.3.1. Define a New Type Definition Package</a></li>
<li><a href="components.html#_using-a-type-definition-package">12.5.3.2. Using a Type Definition Package</a></li>
<li><a href="components.html#_rational">12.5.3.3. Rational</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="components.html#_modules">12.6. Modules</a></li>
<li><a href="components.html#_api-and-implementation-component">12.7. API and Implementation Component</a>
<ul class="sectlevel3">
<li><a href="components.html#_execution-of-api-and-implementation-components">12.7.1. Execution of API and Implementation Components</a></li>
<li><a href="components.html#_api-and-implementation-with-di">12.7.2. API and Implementation With DI</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="plainjs.html#_plainjs">13. PlainJS</a>
<ul class="sectlevel2">
<li><a href="plainjs.html#_type-inference-and-validation-for-plain-js">13.1. Type Inference and Validation for Plain JS</a></li>
<li><a href="plainjs.html#_external-declarations">13.2. External Declarations</a>
<ul class="sectlevel3">
<li><a href="plainjs.html#_declaring-externals">13.2.1. Declaring externals</a></li>
<li><a href="plainjs.html#_instantiating-external-classes">13.2.2. Instantiating external classes</a></li>
<li><a href="plainjs.html#_implementation-of-external-declarations">13.2.3. Implementation of External Declarations</a></li>
<li><a href="plainjs.html#_example">13.2.4. Example</a></li>
</ul>
</li>
<li><a href="plainjs.html#_global-definitions">13.3. Global Definitions</a></li>
<li><a href="plainjs.html#_runtime-definitions">13.4. Runtime Definitions</a></li>
<li><a href="plainjs.html#_applying-polyfills">13.5. Applying Polyfills</a></li>
</ul>
</li>
<li><a href="jsdoc.html#_jsdoc-2">14. JSDoc</a>
<ul class="sectlevel2">
<li><a href="jsdoc.html#_general-n4jsdoc-features">14.1. General N4JSDoc Features</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#_provided-inline-tags">14.1.1. Provided Inline Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag__code">14.1.1.1. @code</a></li>
<li><a href="jsdoc.html#jsdoc_tag__link">14.1.1.2. @link</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="jsdoc.html#_n4jsdoc-for-user-projects">14.2. N4JSdoc for User Projects</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#_standard-tags">14.2.1. Standard Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#_-author">14.2.1.1. @author</a></li>
<li><a href="jsdoc.html#jsdoc_tag_param">14.2.1.2. @param</a></li>
<li><a href="jsdoc.html#jsdoc_tag_return">14.2.1.3. @return</a></li>
</ul>
</li>
<li><a href="jsdoc.html#_test-related-tags">14.2.2. Test Related Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag__testee">14.2.2.1. @testee</a></li>
<li><a href="jsdoc.html#jsdoc_tag__testeeFromType">14.2.2.2. @testeeFromType</a></li>
<li><a href="jsdoc.html#_testeeType_and__testeeMember">14.2.2.3. @testeeType and @testeeMember</a></li>
<li><a href="jsdoc.html#jsdoc_tag_reqid_in_Tests">14.2.2.4. @reqid in Tests</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="jsdoc.html#_n4jsdoc-for-api-and-implementation-projects">14.3. N4JSDoc for API and Implementation Projects</a>
<ul class="sectlevel3">
<li><a href="jsdoc.html#jsdoc_tag__apiNote">14.3.1. @apiNote</a></li>
<li><a href="jsdoc.html#API_Project_Tags">14.3.2. API Project Tags</a>
<ul class="sectlevel4">
<li><a href="jsdoc.html#jsdoc_tag_apiState">14.3.2.1. @apiState</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="jsx.html#_jsx">15. JSX</a>
<ul class="sectlevel2">
<li><a href="jsx.html#_jsx-support">15.1. JSX Support</a></li>
<li><a href="jsx.html#_jsx-backend">15.2. JSX Backend</a></li>
</ul>
</li>
<li><a href="grammars.html#_grammars">16. Grammars</a>
<ul class="sectlevel2">
<li><a href="grammars.html#_type-expressions-grammar">16.1. Type Expressions Grammar</a></li>
<li><a href="grammars.html#_n4js-language-grammar">16.2. N4JS Language Grammar</a></li>
</ul>
</li>
<li><a href="jsobjects.html#_jsobjects">17. JSObjects</a>
<ul class="sectlevel2">
<li><a href="jsobjects.html#_object">17.1. Object</a></li>
<li><a href="jsobjects.html#_string">17.2. String</a></li>
<li><a href="jsobjects.html#_boolean">17.3. Boolean</a></li>
<li><a href="jsobjects.html#_number">17.4. Number</a>
<ul class="sectlevel3">
<li><a href="jsobjects.html#_static-attributes">17.4.1. Static Attributes</a></li>
</ul>
</li>
<li><a href="jsobjects.html#function">17.5. Function</a></li>
<li><a href="jsobjects.html#_error">17.6. Error</a></li>
<li><a href="jsobjects.html#_array">17.7. Array</a></li>
<li><a href="jsobjects.html#_date">17.8. Date</a></li>
<li><a href="jsobjects.html#_math">17.9. Math</a>
<ul class="sectlevel3">
<li><a href="jsobjects.html#static-attributes-1">17.9.1. Static Attributes</a></li>
</ul>
</li>
<li><a href="jsobjects.html#_regexp">17.10. RegExp</a></li>
<li><a href="jsobjects.html#_json">17.11. JSON</a></li>
</ul>
</li>
<li><a href="n4js_objects.html#_n4js-objects">18. N4JS Objects</a>
<ul class="sectlevel2">
<li><a href="n4js_objects.html#_reflection-model">18.1. Reflection Model</a></li>
<li><a href="n4js_objects.html#_error-types">18.2. Error Types</a>
<ul class="sectlevel3">
<li><a href="n4js_objects.html#_n4apinotimplemented">18.2.1. N4ApiNotImplemented</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="appendix_a_acronyms.html#_acronyms">Appendix A: Acronyms</a></li>
<li><a href="appendix_b_license.html#sec:License">Appendix B: License</a></li>
<li><a href="appendix_c_bibliography.html#_bibliography">Appendix C: Bibliography</a></li>
</ul>
</div>
</div>
<div id="content"><div class="sect1">
<h2 id="_expressions"><a class="anchor" href="#_expressions"></a><a class="link" href="#_expressions">8. Expressions</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>For all expressions, we define the following pseudo properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>containingExpression</code> </dt>
<dd>
<p>The parent expression, in which an expression is contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>containingStatement</code> </dt>
<dd>
<p>The statement in which the expression is (indirectly) contained.</p>
</dd>
<dt class="hdlist1"><code>containingFunctionOrAccessor</code> </dt>
<dd>
<p>The function, method, getter or setter in which the expression is (indirectly) contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>containingClass</code> </dt>
<dd>
<p>The class in which the expression is (indirectly) contained, may be null.</p>
</dd>
<dt class="hdlist1"><code>probableThisTarget</code> </dt>
<dd>
<p>The potential target of a this keyword binding, this is not necessarily the containing class or object literal.
In case of instance methods of a class <code>T</code>, this usually is the classifier <code>T</code>; in case of static methods, it is the classifier type <code>type{type}</code>.</p>
</dd>
<dt class="hdlist1"><code>container</code> </dt>
<dd>
<p>The direct owner of the expression.
z</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>The expressions and statements are ordered, describing first the constructs available in the 5th edition of ECMA-262, referred to as [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a</a>] in the following.
It is worth noting that the grammar snippets already use newer constructs in some cases.</p>
</div>
<div class="sect2 language-n4js">
<h3 id="_ecmascript-5-expressions"><a class="anchor" href="#_ecmascript-5-expressions"></a><a class="link" href="#_ecmascript-5-expressions">8.1. ECMAScript 5 Expressions</a></h3>
<div class="paragraph">
<p>N4JS supports the same expressions as ECMAScript.
The semantics are described in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11)</a>].
In N4JS, some expressions are extended for supporting the declaration of types, annotations, or parameterized usages.
These extensions and type-related aspects as well as specific N4JS constraints are described in this section.</p>
</div>
<div class="paragraph">
<p>Some operators come in different ’flavors’, that is as binary operator, unary pre- or postfix operators, or assignment operators.
For these operators, type constraints are only defined for the binary operator version and the other variants are deduced to that binary version.
E.g., <code>++</code> and <code>+=</code> are deduced to <code>+</code> (and simple assignment).</p>
</div>
<div class="sect3">
<h4 id="_the-this-literal"><a class="anchor" href="#_the-this-literal"></a><a class="link" href="#_the-this-literal">8.1.1. The this Literal</a></h4>
<div class="paragraph">
<p>This section describes the <code>this</code> literal and the semantics of the <code>@This</code> annotation, the type <code>this</code> is described in <a href="types.html#_this-type">This Type</a>.</p>
</div>
<h5 id="_semantics-9" class="discrete">Semantics</h5>
<div class="paragraph">
<p>Semantics are similar to the original ECMAScript this keyword, see [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.11.1.1, p.p.63)</a>])
Also see [<a href="appendix_c_bibliography.html#West06a">West06a</a>] and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this">MozillaJSRef</a></p>
</div>
<div class="paragraph">
<p>Regarding the location where <code>this</code> may be used, the following restrictions apply:</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-173"></a><strong>Req. IDE-173:</strong> <a href="#Req-IDE-173">Valid location for this literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>The literal may not be used in</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>the initializer expression of static data fields in classes.</p>
</li>
<li>
<p>the initializer expression of data fields in interfaces (applies to both static and non-static).</p>
</li>
<li>
<p>static methods of interfaces and static field accessors of interfaces.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>See also <a href="classifiers.html#Req-IDE-69">[Req-IDE-69]</a>.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>Note: <a href="#Req-IDE-173">[Req-IDE-173]</a> also applies for this literals inside arrow expressions in initializers.</p>
</div>
<div class="paragraph">
<p>The use of <code>this</code> is illustrated with some examples as it can often be confusing.
Type inference heuristics and explanations are provided in the next section.</p>
</div>
<div class="exampleblock">
<div class="title">Example 76. This in Unrestricted Mode</div>
<div class="content">
<div class="paragraph">
<p>In unrestricted mode, <code>this</code> is bound to the receiver.
If there is no receiver it is bound to the global object, however, we often do not know exactly what the global object would be.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var name = "global a"; // assume the top level is similar to the global object
this.name; // &lt;-- "global a"
function f() {
    return this.name; // &lt;-- depends on call, usually "global a"
}
var ol1 = {
    name: "John",
    greeting: "Hello " + this.name, // "Hello global a" -- we do not greet John!
}
var ol2 = {
    name: "John",
    f: function() {
        this.name; // usually "John", as we assume f is called like ol2.f()
        var g = function() {
           return this.name; // "global a"
        }
        return g(); // no receiver, this in nested function g will be global scope
    }
}</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 77. This in strict mode</div>
<div class="content">
<div class="paragraph">
<p>In strict mode, <code>this</code> is bound to the receiver.
If there is no receiver, it is bound to <code>undefined</code>.
Thus, we will probably get a lot of errors:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">"use strict"
var name = "global a"; // assume the top level is similar to the global object
this.name; // &lt;-- error, this is undefined, there is no receiver
function f() {
    return this.name; // &lt;-- depends on call, usually this produces an error as this is undefined
}
var ol1 = {
    name: "John",
    greeting: "Hello " + this.name, // will produce an error, as this is undefined
}
var ol2 = {
    name: "John",
    f: function() {
        this.name; // usually "John", as we assume f is called like ol2.f()
        var g = function() {
           this.name; // an error, see call below:
        }
        return g(); // no receiver, this in nested function g is undefined
    }
}</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 78. This in N4JS mode</div>
<div class="content">
<div class="paragraph">
<p>As in strict mode, <code>this</code> is bound to the receiver and if there is no receiver, it is bound to <code>undefined</code>. So the example above is also true for N4JS mode.
Classes behave slightly differently:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A {
    name = "John";
    greeting  = "Hello " + this.name; // works, in N4JS classes, greeting is "Hello John"

    f() {
        return this.name; // this usually is instance object, similar to object literals.
    }

    g() {
        var h = function() {
            return this.name; // as in object literals: no receiver, no this.
        }
        return h();
    }
}</code></pre>
</div>
</div>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title=""></i>
</td>
<td class="content">
In N4JS classes, <code>this</code> is always bound to the instance when used in field initialization.
</td>
</tr>
</table>
</div>
<h5 id="_type-inference-2" class="discrete">Type Inference</h5>
<div class="openblock language-n4js">
<div class="content">
<div class="paragraph">
<p>The type is inferred from the <code>this</code> type is bound to. The inference,
therefore, has to consider the original semantics as described in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.4., p.10.4.3, p.p.58)</a>].
In ECMAScript the type of this is unfortunately determined by the function call and not by the function definition:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>By default, <code>this</code> is bound to the global object [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.4.1.1)</a>].
Unfortunately it is often unknown what the global object will be at run time (e.g., node.js differs from browsers).</p>
</li>
<li>
<p>If a function is called without a receiver, <code>this</code> is bound to</p>
<div class="ulist">
<ul>
<li>
<p>the global object or</p>
</li>
<li>
<p>to <code>undefined</code> in strict mode.</p>
</li>
</ul>
</div>
</li>
<li>
<p>If a function is called with a receiver,<code>this</code> is bound to the receiver object.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Actually, <code>this</code> is bound to the newly created object if a function is called with the <code>new</code> operator.
If a function is known to be invoked with an explicit <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>t</mi><mi>h</mi><mi>i</mi><mi>s</mi><mi>A</mi><mi>r</mi><mi>g</mi></math> (<code>apply()</code> etc.), the <code>@This</code> annotation can be used to explicitly set the this type.
This annotation has precedence over otherwise inferred bindings.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-90"></a><strong>Req. IDE-90:</strong> <a href="#Req-IDE-90">Type Inference Heuristic for This-Keyword</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>In general, the actual this target can not be inferred from the context of the this keyword.
A heuristic is defined, however, to compute the probable this type:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a id="this-keyword-constraint-1"></a> If the this keyword is used in some function annotated with an annotation <code>@This</code>, the type specified in the annotation is used.
The inferred type is always nominal.</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>O</mi><mi>r</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mi>f</mi><mo>.</mo><mi>h</mi><mi>a</mi><mi>s</mi><mi>A</mi><mi>n</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close=")" open="("><mstyle mathvariant="monospace"><mtext>"@This"</mtext></mstyle></mfenced><mspace width="3.0mm"/><mi>T</mi><mo>=</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>n</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mstyle mathvariant="monospace"><mtext>["@This"]</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mo>≁</mo><mi>T</mi></mrow></mfrac></math></p>
</div>
</li>
<li>
<p><a id="this-keyword-constraint-2"></a> If the this keyword is used in some <em>instance</em> method of a  classifier or in an <em>instance</em> field initializer,<code>this</code> is bound to the <code>T</code> itself.
If the this keyword is used in some <em>static</em> method of a classifier <code>T</code> or in a <em>static</em> field initializer, the prototype type (or constructor) of the classifier is used, that is <code>type[T]</code>.
In both cases, the target is determined by using the expressions’s pseudo property <code>probableThisTarget</code>.
If the this keyword is used in a function expression assigned to an property of an object literal, the type of the object literal is used.
Note that usually this is the <code>this</code> type in instance methods, and the <code>this</code> type in static methods.</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>T</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>b</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi><mi>T</mi><mi>h</mi><mi>i</mi><mi>s</mi><mi>T</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mspace width="3.0mm"/><mi>T</mi><mo>≠</mo><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mo>≁</mo><mi>T</mi></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</li>
<li>
<p>In all other cases: Non-strict mode:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>unrestricted</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>global</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>Strict mode and N4JS mode:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>≠</mo><mstyle mathvariant="monospace"><mtext>unrestricted</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>global</mtext></mstyle><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>If the actual this type is defined as a structural type, the structural type information is moved to the this type itself.
This is transparent to the user in general but maybe visible in case of error messages.
That is to say that the actual this type is always a nominal type.
This is indicated by the nominal modifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mo>≁</mo></math> (cf. <a href="#Req-IDE-90">[Req-IDE-90]</a> constraints <a href="#this-keyword-constraint-1">1</a> and <a href="#this-keyword-constraint-2">2</a>.).</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-91"></a><strong>Req. IDE-91:</strong> <a href="#Req-IDE-91">Valid Target and Argument for @This Annotation</a> (ver. 1)</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The <code>@This</code> annotation is only allowed on declared functions, function expressions (including arrow functions), methods, and field accessors, i.e. getters and setters, except static members of interfaces.</p>
</li>
<li>
<p>The type declared by way of <code>@This(..)</code> an annotation of a method or field accessor must be a subtype of the member’s containing classifier.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-92"></a><strong>Req. IDE-92:</strong> <a href="#Req-IDE-92">Single @This Annotation</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>It is not allowed to use more then one <code>@This(..)</code> annotation on an element.</p>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 79. Effect of Nominal This Type</div>
<div class="content">
<div class="paragraph">
<p>Given the following declaration</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">@This(~Object with {a: string;}) f() {}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Since the this type is always nominal, <code>~ Object</code> becomes <code>Object</code>.
In case of method call, however, the returned value becomes structural again.
In case of error messages the type of the return type is then</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">~this[Object] with {a: string;}</code></pre>
</div>
</div>
<div class="paragraph">
<p>For the sake of simplicity, additional structural members are usually
omitted in error messages, leading to</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">~this[Object]</code></pre>
</div>
</div>
<div class="paragraph">
<p>instead of</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">this[~Object]</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 80. This and Function Declaration</div>
<div class="content">
<div class="paragraph">
<p>This example demonstrates the usage of functions annotated with <code>@This</code>.
By using the argument  <code>union{A,B}</code> it is possible to have two completely unrelated classes as the receiver type of the function <code>logger</code>.
To pass an actual object the <code>apply()</code> method of the function is used.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A {
    log: string() { return "A was logged"; }
}

class B {
    log: string() { return "B was logged"; }
}

@This(union{A,B})
function logger() { console.log("~ "+this.log()+" ~"); }


var a: A = new A();
logger.apply(a,[]); // prints "~ A was logged ~"
logger.apply( new B(),[]) // prints "~ B was logged ~"</code></pre>
</div>
</div>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 81. This and Function Expressions</div>
<div class="content">
<div class="paragraph">
<p>In this example a function is created via a function expression.
The function is then assigned to member field of class B.
Via annotating the expression with <code>@This(B)</code>, access to the receiver of type B is enabled.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class B {
    log(): string { return "B was logged"; }     // method
    logMe : {@This(B) function():void}; // reference to a function
}

var b: B = new B();
b.logMe = @This(B) function() { console.log("*&gt;"+this.log()+"&lt;*"); }
b.logMe(); // prints "*&gt;B was logged&lt;*"</code></pre>
</div>
</div>
<div class="openblock">
<div class="content">

</div>
</div>
<div class="paragraph">
<p>Note that if a function is called as a constructor function with new, the
type of <code>this</code> can be declared via annotation <code>@This(..)</code>, as shown in the following
snippet:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">@This(
    ~Object with {
        w: number; h: number;
        area: {function():number};
    })
function Box(w: number w, h: number) {
    this.w = w;
    this.h = h;
    this.area = @This(
        ~Object with {
            w: number; h: number;
            area: {function():number};
        }) function() { return this.w * this.h }
}
var bError = Box(1,2)
var bOK = new Box(1,2)</code></pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>Inside the constructor function <code>Box</code>, <code>this</code> is bound to the structural type definition due to the annotation.</p>
</div>
<div class="paragraph">
<p>Inside the nested function <code>area</code>, <code>this</code> is bound to the receiver object (if the function is called like <code>bOk.area()</code>).
Again, this depends on the way the nested function is called, which can usually not be determined at the declaration location.
The nested function must then be annotated accordingly.</p>
</div>
<div class="paragraph">
<p>When calling this function, the type of this is checked against the declared this type, which would cause an error in the first case.</p>
</div>
<div class="paragraph">
<p>The use of the <code>@This</code> annotation is not allowed on methods.</p>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title=""></i>
</td>
<td class="content">
Using constructor functions is not recommended and an error or warning will be created.
This is only useful for adapting third-party library code.
Even in the latter case, it would probably make more sense to declare a (library) <strong>class</strong> Rectangle rather then defining the constructor function.
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="_identifier"><a class="anchor" href="#_identifier"></a><a class="link" href="#_identifier">8.1.2. Identifier</a></h4>
<h5 id="_syntax-10" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Identifiers as expressions are identifier references.
They are defined as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">IdentifierRef &lt;Yield&gt;:
    id=[types::IdentifiableElement|BindingIdentifier&lt;Yield&gt;]
;

BindingIdentifier &lt;Yield&gt;:
    IDENTIFIER
    | &lt;!Yield&gt; 'yield'
    | N4Keyword
;</code></pre>
</div>
</div>
<h5 id="_semantics-10" class="discrete">Semantics</h5>
<div class="paragraph">
<p>The type of an identifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is resolved depending on its binding and scope respectively (cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.10.2.2.1GetIdentifierReference, p.p.56)</a>].
The following scopes (aka <em>Lexical Environments</em>) are defined:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>function local; local variables, parameters</p>
</li>
<li>
<p>zero or more function closure in case of nested functions</p>
</li>
<li>
<p>module</p>
</li>
<li>
<p>global</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These scope are nested as illustrated in <a href="#fig:scopes">Scopes</a>.</p>
</div>
<div class="paragraph">
<p>Note that classes definitions and object literal do not define a scope: members of a class or properties of an object literal are to be accessed via <code>this</code>.
Identifier references always reference declared elements, that is to say either variable, function, or class declarations.
Properties of object literals or members of a class are referenced via <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>P</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>-</mo><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi></math> (see <a href="#_property-accessors">Property Accessors</a>).</p>
</div>
<div id="fig:scopes" class="imageblock" style="text-align: center">
<div class="content">
<img src="chapters/08_expressions/fig/scopes.svg" alt="scopes">
</div>
<div class="title">Figure 7. Scopes</div>
</div>
<div class="paragraph">
<p>An identifier may be bound to a variable (global or local variable, parameter, variable defined in a function’s closure), or to a property of an object.
The latter case is known as property access as further described in <a href="#_property-accessors">Property Accessors</a>.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-93"></a><strong>Req. IDE-93:</strong> <a href="#Req-IDE-93">Read Access to Identifier</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>If an identifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is accessed, the bound declared element <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>D</mi></math> must be readable if it is not used on the left-hand side of an assignment expression.</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mi>i</mi><mi>D</mi></mfenced></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="2.0em"/><mo>∧</mo><mo>∄</mo><mi> </mi><mstyle mathvariant="monospace"><mtext>AssignmentExpression</mtext></mstyle><mi> </mi><mi>a</mi><mi>e</mi><mo>∈</mo><mi>i</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><msup><mi>r</mi><mo>*</mo></msup><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="3.0em"/><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mo>=</mo><mi>i</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mspace width="4.0em"/><mo>∨</mo><mfenced close=")" open="("><mrow><mi>μ</mi><mfenced close=")" open="("><mrow><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyAccessExpression</mtext></mstyle><mo>∧</mo><mi>a</mi><mi>e</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mo>=</mo><mi>i</mi></mrow></mfenced><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mo>⇒</mo><mi>D</mi><mo>.</mo><mi>r</mi><mi>e</mi><mi>a</mi><mi>d</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi></math></p>
</div>
</div>
</div>
<h5 id="_type-inference-3" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>An identifier reference <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> is bound to an identifiable element <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mo>.</mo><mi>i</mi><mi>d</mi></math>, which is expressed with the function <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mi>i</mi><mrow><mi>i</mi><mo>.</mo><mi>i</mi><mi>d</mi></mrow></mfenced></math>.
The type of the reference is then inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>i</mi><mi>d</mi><mi>r</mi><mi>e</mi><mi>f</mi><mo>.</mo><mi>i</mi><mi>d</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>IdentifierRef</mtext></mstyle><mi> </mi><mi>i</mi><mi>d</mi><mi>r</mi><mi>e</mi><mi>f</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_literals"><a class="anchor" href="#_literals"></a><a class="link" href="#_literals">8.1.3. Literals</a></h4>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.3p.63, p.S7.8p.19ff)</a>].</p>
</div>
<h5 id="_type-inference-4" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of a literal can directly be derived from the grammar.
The following axioms are defined for literals:</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>NullLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>BooleanLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>NumericLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>int</mtext></mstyle><mi>o</mi><mi>r</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>StringLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>string</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="13.0em"/><mfrac><mrow/><mrow><mstyle mathvariant="monospace"><mtext>RegularExpressionLiteral</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>RegExpr</mtext></mstyle></mrow></mfrac></math></p>
</div>
<div class="paragraph">
<p>Note that there are no literals specific for <code>pathSelector</code> or <code>i18nkey</code>.</p>
</div>
<div class="sect4">
<h5 id="_integer-literals"><a class="anchor" href="#_integer-literals"></a><a class="link" href="#_integer-literals">8.1.3.1. Integer Literals</a></h5>
<div class="paragraph">
<p>Numeric literals representing integers in the range of JavaScript’s int32 are inferred to the built-in primitive type <code>int</code> instead of <code>number</code>.
The following rules apply:</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-94"></a><strong>Req. IDE-94:</strong> <a href="#Req-IDE-94">Numeric literals</a> (ver. 1)</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Numeric literals with a fraction or using scientific notation, e.g. <code>2.0</code> and <code>2e0</code>, respectively, are always inferred to <code>number</code>, even if they represent integers in the range of int32.</p>
</li>
<li>
<p>Numeric literals that represent integers in the range of JavaScript’s int32, i.e. from <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mn>-2</mn><mn>31</mn></msup></math> to <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mn>2</mn><mn>31</mn></msup><mo>-</mo><mn>1</mn></math>, are inferred to <code>int</code>.</p>
</li>
<li>
<p>Hexadecimal and octal literals are always interpreted as positive numbers, so all values above <code>0x7fffffff</code> and <code>017777777777</code> lie outside the range of int32 and will thus
be inferred to <code>number</code>; this is an important difference to Java. See below for further elaboration.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There are differences to numeric literals in Java:</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 12.5%;">
<col style="width: 25%;">
<col style="width: 12.5%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-center valign-top" colspan="2">Java</th>
<th class="tableblock halign-center valign-top" colspan="2">JavaScript  N4JS</th>
</tr>
</thead>
<tbody>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock">Literal</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Value</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Value</p></th>
<th class="tableblock halign-left valign-top"><p class="tableblock">Type</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>2147483648</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>2147483647</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x7fffffff</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x80000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>+2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0xffffffff</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-1</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967295</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0x100000000</code></p></td>
<th class="tableblock halign-center valign-top" colspan="2"><p class="tableblock">n/a</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967296</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>017777777777</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>2147483647</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>020000000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>+2147483648</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>037777777777</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>-1</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967295</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>040000000000</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>0</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>4294967296</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0100000000000</code></p></td>
<th class="tableblock halign-center valign-top" colspan="2"><p class="tableblock">n/a</p></th>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>8589934592</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The literals <code>0x100000000</code> and <code>0100000000000</code> produce a syntax error in Java.</p>
</div>
<div class="paragraph">
<p>Until IDE-1881  is complete, all built-in operations always return a <code>number</code> even if all operands are of type <code>int</code>.
For the time being, we therefore interpret <code>-1</code> as a negative integer literal (inferred to <code>int</code>), but <code>-(1)</code> as the negation of a positive integer literal (inferred to <code>number</code>).</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_array-literal"><a class="anchor" href="#_array-literal"></a><a class="link" href="#_array-literal">8.1.4. Array Literal</a></h4>
<h5 id="_syntax-11" class="discrete">Syntax</h5>
<div class="paragraph">
<p>cf [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.4, p.p.63)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ArrayLiteral &lt;Yield&gt; returns ArrayLiteral:
    {ArrayLiteral} '['
        elements+=ArrayPadding* (
            elements+=ArrayElement&lt;Yield&gt;
            (',' elements+=ArrayPadding* elements+=ArrayElement&lt;Yield&gt;)*
            (trailingComma?=',' elements+=ArrayPadding*)?
        )?
    ']'
;

/**
 * This array element is used to pad the remaining elements, e.g. to get the
 * length and index right
 */
ArrayPadding returns ArrayElement: {ArrayPadding} ',';

ArrayElement &lt;Yield&gt; returns ArrayElement: {ArrayElement} spread?='...'? expression=AssignmentExpression&lt;In=true,Yield&gt;;</code></pre>
</div>
</div>
<h5 id="_type-inference-5" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>In general, an array literal is inferred as <code>Array&lt;T&gt;</code> (similar to the type of <code>new Array()</code>).
The interesting question is the binding of the type variable <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi></math>.</p>
</div>
<div class="paragraph">
<p>The type of an array padding <em>p</em> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
<div class="paragraph">
<p>The element type of an array literal is simply inferred as the (simplified) union of the type elements of the array.
Thus, the type of an array literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>a</mi><mo>.</mo><mover accent="true"><mrow><mi>e</mi><mi>l</mi><mi>e</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi></mrow><mo>¯</mo></mover><mi>:</mi><mover accent="true"><msub><mi>T</mi><mi>e</mi></msub><mo>¯</mo></mover><mi>T</mi><mo>=</mo><mo>⋃</mo><mover accent="true"><msub><mi>T</mi><mi>e</mi></msub><mo>¯</mo></mover></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mfenced close=")" open="("><mi>a</mi></mfenced><mi>:</mi><mi>A</mi><mi>r</mi><mi>r</mi><mi>a</mi><mi>y</mi><mo>&lt;</mo><mi>T</mi><mo>&gt;</mo></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>In other languages not supporting union types, the element type is often inferred as the join (<a href="appendix_a_acronyms.html#_acronyms">LCST</a>) of the element types.
Using a union type here preserves more information (as the actual types are still known).
For many use cases the behavior is similar though, as the members of a union type are the members of the join of the elements of the union.</p>
</div>
<div class="paragraph">
<p>Note that <code>typeof [1,2,3]</code> does not return <code>Array&lt;number&gt;</code> (as ECMAScript is not aware of the generic array type), but <code>Object</code>.</p>
</div>
<div class="exampleblock">
<div class="title">Example 82. Array Type Inference</div>
<div class="content">
<div class="paragraph">
<p>The type for all variables declared in this example is inferred to <code>Array&lt;string&gt;</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var names1          = ["Walter", "Werner"];
var names2          = new Array("Wim", "Wendelin");
var names3          = new Array&lt;string&gt;(3); // length is 3
var names4: Array&lt;string&gt;;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Empty array literals are inferred to <code>any</code>, by default.
We are not using <code>Array&lt;?&gt;</code> here because then a typical JavaScript pattern would no longer be supported:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var a = [];
a.push('hello'); <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>This would fail if <code>a</code> and thus <code>[]</code> were inferred to <code>Array&lt;?&gt;</code></td>
</tr>
</table>
</div>
</div>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title=""></i>
</td>
<td class="content">
An important exception; if a type expectation exists for the empty array literal and the expected type is <code>Array&lt;T&gt;</code>, this will be used as the type of the array literal.
</td>
</tr>
</table>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-95"></a><strong>Req. IDE-95:</strong> <a href="#Req-IDE-95">Empty array literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>An empty array literal will be inferred as follows:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If there is a type expectation for the empty array literal and the expected type is <code>Array&lt;T&gt;</code>, for any type <code>T</code>, then the type of the empty array literal will be inferred to <code>Array&lt;T&gt;</code>.</p>
</li>
<li>
<p>Otherwise, the type of the empty array literal will be inferred to <code>Array&lt;any&gt;</code>.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_object-literal"><a class="anchor" href="#_object-literal"></a><a class="link" href="#_object-literal">8.1.5. Object Literal</a></h4>
<div class="paragraph">
<p>In addition to ordinary Javascript object literals, N4JS supports the spread operator within object literals as introduced in [<a href="appendix_c_bibliography.html#ECMA18a">ECMA18a</a>].</p>
</div>
<h5 id="object-literal-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.5, p.p.65ff)</a>]
The syntax of an object literal is given by:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ObjectLiteral &lt;Yield&gt;: {ObjectLiteral}
    '{'
        ( propertyAssignments+=PropertyAssignment&lt;Yield&gt;
          (',' propertyAssignments+=PropertyAssignment&lt;Yield&gt;)* ','?
        )?
    '}'
;

PropertyAssignment &lt;Yield&gt;:
      PropertyNameValuePair&lt;Yield&gt;
    | PropertyGetterDeclaration&lt;Yield&gt;
    | PropertySetterDeclaration&lt;Yield&gt;
    | PropertyMethodDeclaration&lt;Yield&gt;
    | PropertyNameValuePairSingleName&lt;Yield&gt;
    | PropertySpread&lt;Yield&gt;
;


PropertyMethodDeclaration &lt;Yield&gt;:
    =&gt; ({PropertyMethodDeclaration}
        annotations+=Annotation*
        TypeVariables? returnTypeRef=TypeRef?
            (
                generator?='*'  LiteralOrComputedPropertyName&lt;Yield&gt; -&gt;MethodParamsAndBody&lt;Generator=true&gt;
                | LiteralOrComputedPropertyName&lt;Yield&gt; -&gt;MethodParamsAndBody &lt;Generator=false&gt;
            )
        )
    ';'?
;

PropertyNameValuePair &lt;Yield&gt;:
    =&gt; (
        {PropertyNameValuePair}
        annotations+=Annotation*
        declaredTypeRef=TypeRef? LiteralOrComputedPropertyName&lt;Yield&gt; ':'
    )
    expression=AssignmentExpression&lt;In=true,Yield&gt;
;

/*
 * Support for single name syntax in ObjectLiteral (but disallowed in actual object literals by ASTStructureValidator
 * except in assignment destructuring patterns)
 */
PropertyNameValuePairSingleName &lt;Yield&gt;:
    declaredTypeRef=TypeRef?
    identifierRef=IdentifierRef&lt;Yield&gt;
    ('=' expression=AssignmentExpression&lt;In=true,Yield&gt;)?
;

PropertyGetterDeclaration &lt;Yield&gt;:
    =&gt;(
        {PropertyGetterDeclaration}
        annotations+=Annotation*
        GetterHeader&lt;Yield&gt;
    )
    body=Block&lt;Yield=false&gt;
;

PropertySetterDeclaration &lt;Yield&gt;:
    =&gt;(
        {PropertySetterDeclaration}
        annotations+=Annotation*
        'set'
        -&gt;LiteralOrComputedPropertyName &lt;Yield&gt;
    )
    '(' fpar=FormalParameter&lt;Yield&gt; ')' body=Block&lt;Yield=false&gt;
;

PropertySpread &lt;Yield&gt;:
	'...' expression=AssignmentExpression&lt;In=true,Yield&gt;
;</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">import Address from "my/Address";
var simple = {name: "Walter", age: 72, address: new Address()};</code></pre>
</div>
</div>
<div class="sect4">
<h5 id="_properties-6"><a class="anchor" href="#_properties-6"></a><a class="link" href="#_properties-6">8.1.5.1. Properties</a></h5>
<div class="paragraph">
<p>PropertyAssignments have common properties of PropertyNameValuePair, PropertyGetterDeclaration, and PropertySetterDeclaration:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>annotations</code> </dt>
<dd>
<p>The annotations of the property assignment.</p>
</dd>
<dt class="hdlist1"><code>name</code> </dt>
<dd>
<p>The name of the property. This may be an identifier, a string or a numeric literal.
When comparing names, we implicitly assume the name to be converted to an identifier, even if this identifier is not a valid ECMAScript identifier.</p>
</dd>
<dt class="hdlist1"><code>declaredType</code> </dt>
<dd>
<p>The declared type of the property which may be null.
This property is a pseudo property for PropertySetterDeclaration, in this case it is derived from the declared type of the setter’s formal parameter.</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>Additionally, we introduce the following pseudo properties to simplify constraints:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>isAccessor</code> </dt>
<dd>
<p>The read-only boolean property. This is true if the property assignment is a setter or getter declaration.
This is comparable to ECMAScript’s spec function <code>IsAccessoprDescriptor</code>.
For a given property assignment <em>p</em> this is semantically equivalent to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyGetterDeclaration</mtext></mstyle><mo>∨</mo><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertySetterDeclaration</mtext></mstyle></math>.</p>
</dd>
<dt class="hdlist1"><code>isData</code> </dt>
<dd>
<p>The read-only boolean property.
This is true if the property assignment is a name value pair.
For a given property assignment <em>p</em> this is semantically equivalent to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyNameValuePair</mtext></mstyle></math>.
It is comparable to ECMAScript’s spec function <code>isDataDescriptor</code>.
The equation <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mo>=</mo><mo>¬</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi></math> is always true.</p>
</dd>
</dl>
</div>
<h5 id="properties-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-96"></a><strong>Req. IDE-96:</strong> <a href="#Req-IDE-96">Object literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given object literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>o</mi><mi>l</mi></math> the following constraints must hold (cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the name of each property is given as an identifier, a string literal, a numeric literal, or as a computed property name with a compile-time expression (see <a href="#compile-time-expressions">Compile-Time Expressions</a>). In particular, string literals, e.g. <code>['myProp']</code>, built-in symbols, e.g. <code>[Symbol.iterator]</code>, and literals of <code>@StringBased</code> enums are all valid computed property names.</p>
</li>
<li>
<p>Object literal may not have two PropertyNameValuePairs with the same name in strict mode (cf. 4.a [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>strict</mtext></mstyle><mo>→</mo><mspace width="3.0mm"/><mo>∀</mo><mi>p</mi><mi>a</mi><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mo>∄</mo><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo>.</mo><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mo>∧</mo><mi>p</mi><msup><mi>a</mi><mi>'</mi></msup><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
<li>
<p>Object literal may not have PropertyNameValuePair and <code>PropertyGetterDeclaration</code>/<code>PropertySetterDeclaration</code> with the same name (cf. 4.b/c [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∀</mo><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>a</mi><mi>t</mi><mi>a</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∄</mo><mspace width="3.0mm"/><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi></mrow></mfenced><mo>≠</mo><mstyle mathvariant="monospace"><mtext>PropertyNameValuePair</mtext></mstyle><mo>∧</mo><mi>p</mi><mi>g</mi><mi>s</mi><mi>d</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
<li>
<p>Object literal may not have multiple <code>PropertyGetterDeclaration</code> or <code>PropertySetterDeclaration</code> with the same name (cf. 4.d [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]):</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∀</mo><mspace width="3.0mm"/><mi>p</mi><mi>g</mi><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mo>,</mo><mi>p</mi><mi>g</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∄</mo><mspace width="3.0mm"/><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mfenced close="}" open="{"><mrow><mi>p</mi><mi>g</mi></mrow></mfenced><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup></mrow></mfenced><mo>=</mo><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>g</mi></mrow></mfenced><mo>∧</mo><mi>p</mi><msup><mi>g</mi><mi>'</mi></msup><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>g</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math></p>
</div>
</li>
</ul>
</div>
<div class="quoteblock">
<blockquote>
It is a SyntaxError if the Identifier <code>eval</code> or the Identifier <code>arguments</code> occurs as the Identifier in a <code>PropertySetParameterList</code> of a <code>PropertyAssignment</code> that is contained in strict code or if its
<code>FunctionBody</code> is strict code. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.66)</a>]
</blockquote>
</div>
<div class="ulist">
<ul>
<li>
<p>If two or more property assignments have the same name (and the previous conditions hold), then the types of these assignments must <em>conform</em>.
That is to say that the inferred (but not declared) type of all assignments must be type of probably declared types and if the types are explicitly declared, they must be equal.</p>
</li>
<li>
<p>In N4JS mode, the name of a property must be a valid N4JSIdentifier:</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>n4js</mtext></mstyle><mo>→</mo><mspace width="3.0mm"/><mo>∀</mo><mi>p</mi><mi>a</mi><mo>∈</mo><mi>o</mi><mi>l</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi><mi>:</mi></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>a</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>N4JSIdentifier</mtext></mstyle></math></p>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-22501"></a><strong>Req. IDE-22501:</strong> <a href="#Req-IDE-22501">Superfluous properties of an object literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math> be the expected type of an object literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> as defined by the context in which <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> is used.
If <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math> is not type <code>Object</code> and not dynamic, then the compiler creates a warning <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> contains properties not found in <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math>.</p>
</div>
<div class="paragraph">
<p>This is true in particular for object literals passed in as arguments of a spec-constructor.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="_scoping-and-linking"><a class="anchor" href="#_scoping-and-linking"></a><a class="link" href="#_scoping-and-linking">8.1.5.2. Scoping and linking</a></h5>
<div class="exampleblock">
<div class="title">Example 83. Scoping and linking</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var p = {
    f: function() {
        console.log("p´s f");
    },
    b: function() {
        this.f();
    },
    o: {
        nested: "Hello"
    }
};
p.b();
p.o.nested;</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Other properties within an object literal property can be accessed using this.
In the expression of property name value pairs, however, <code>this</code> is not be bound to the containing object literal, but usually to undefined or global.</p>
</li>
<li>
<p>The properties of an object literal are accessible from outside.</p>
</li>
<li>
<p>Nested properties of an object literal are also accessible from outside.</p>
</li>
</ul>
</div>
</div>
</div>
<h5 id="type-inference-3" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>An object literal implicitly extends <code>~Object</code>, therefore, object literal types use structural typing.
For details see <a href="classifiers.html#_structural-typing">Structural Typing</a>.
From a type systems point of view, the two variables <code>ol</code> and <code>st</code> below have the same type.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var ol = {
    s: "hello",
    n: 42
}
var st: ~Object with { s: string; n: number;};</code></pre>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_parenthesized-expression-and-grouping-operator"><a class="anchor" href="#_parenthesized-expression-and-grouping-operator"></a><a class="link" href="#_parenthesized-expression-and-grouping-operator">8.1.6. Parenthesized Expression and Grouping Operator</a></h4>
<div class="paragraph">
<p>The grouping operator is defined here as a parenthesized expression.</p>
</div>
<h5 id="parenthesized-expression-grouping-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1.6, p.p.67)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ParenExpression &lt;Yield&gt;: '(' expression=Expression&lt;In=true,Yield&gt; ')';</code></pre>
</div>
</div>
<h5 id="Grouping-Operator-type-inference" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of the grouping operator simply is the type of its nested expression.
The type if a parenthesized expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>e</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>’(’</mtext></mstyle><mi>e</mi><mstyle mathvariant="monospace"><mtext>’)’</mtext></mstyle><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 84. Parenthesized Expression Type Examples</div>
<div class="content">
<div class="paragraph">
<p>In the following listing, the type of the plain expressions is equivalent to the parenthesized versions:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A{} class B extends A{}
var f: boolean; var a: A a; var b: B;

/* simple       &lt;-&gt;     parenthesized */
10;                     (10);
"hello";                ("hello");
true;                   (true);
a;                      (a);
10-5;                   (10-5);
f?a:b                   (f?a:b);</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_property-accessors"><a class="anchor" href="#_property-accessors"></a><a class="link" href="#_property-accessors">8.1.7. Property Accessors</a></h4>
<h5 id="property-accessor-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Property accessors in N4JS are based on [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.1, p.p.67ff)</a>].
They cannot only be used for accessing properties of an object, but also for accessing members of a class instance.
In order to support parameterized calls, the syntax is extended to optionally allow type arguments.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ParameterizedPropertyAccessExpression:
    target=PrimaryExpression&lt;Yield&gt; ParameterizedPropertyAccessExpressionTail&lt;Yield&gt;
;

IndexedAccessExpression:
    target=PrimaryExpression&lt;Yield&gt; IndexedAccessExpressionTail&lt;Yield&gt;
;

fragment IndexedAccessExpressionTail &lt;Yield&gt;*:
    '[' index=Expression&lt;In=true,Yield&gt; ']'
;

fragment ParameterizedPropertyAccessExpressionTail &lt;Yield&gt;*:
    '.' TypeArguments? property=[types::IdentifiableElement|IdentifierName]
;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that in [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a</a>], the <code>index access</code> is called <code><em>bracket notation</em></code>.</p>
</div>
<h5 id="property-access-direct" class="discrete">Direct Property Access</h5>
<div class="paragraph">
<p>We define a special case of property access as follows:</p>
</div>
<div class="openblock definition">
<div class="content">
<div class="paragraph">
<p><a id="direct_property_access"></a><strong>Definition:</strong> <a href="#direct_property_access">Direct Property Access</a></p>
</div>
<div class="paragraph">
<p>A property access expression is called <em>direct</em>, iff</p>
</div>
<div class="ulist">
<ul>
<li>
<p>its target is an identifier reference to a class, interface, enum, or the built-in object <code>Symbol</code>, and</p>
</li>
<li>
<p>its property name denotes an <em>owned</em> member of the target classifier (not an inherited, consumed, or polyfilled member) or a literal if the target is an enum.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="paragraph">
<p>As a consequence, a direct property access can only refer to static members.</p>
</div>
<div class="paragraph">
<p>The first requirement of the above definition rules out property access expressions that do not directly point to their target classifier or enum, as shown in the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class C {
  const field = 'hello';
}
C.field;  // direct property access to 'field'
let ctor = C;
ctor.field;  // *not* a direct property access to 'field'</code></pre>
</div>
</div>
<div class="paragraph">
<p>Direct property access is the only form of property access allowed in compile-time expressions, cf. <a href="#compile-time-expressions">Compile-Time Expressions</a>.</p>
</div>
<div class="sect4">
<h5 id="properties-1"><a class="anchor" href="#properties-1"></a><a class="link" href="#properties-1">8.1.7.1. Properties</a></h5>
<div class="paragraph">
<p>We define the following properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>target</code> </dt>
<dd>
<p>The receiver of the property access.</p>
</dd>
<dt class="hdlist1"><code>index</code> </dt>
<dd>
<p>The index expression in case of an IndexedAccessExpression (returns <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></math> otherwise).</p>
</dd>
<dt class="hdlist1"><code>property</code> </dt>
<dd>
<p>The name of the property in case of non-indexed-access expressions (returns <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></math> otherwise, although the index may be interpreted as property name).</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>We define the following pseudo properties:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>isDotAccess</code> </dt>
<dd>
<p>Read-only boolean property, returns true for non-index access expression (similar to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>≠</mo><mstyle mathvariant="monospace"><mtext>IndexedAccessExpression</mtext></mstyle></math>).</p>
</dd>
<dt class="hdlist1"><code>isIndexAccess</code> </dt>
<dd>
<p>Read-only boolean property, returns true for index access expression (similar to <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>IndexedAccessExpression</mtext></mstyle></math>.<br>
The equation <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>=</mo><mo>¬</mo><mi>p</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>I</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>x</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi></math> is always true.</p>
</dd>
<dt class="hdlist1"><code>name</code> </dt>
<dd>
<p>Returns the name of the property.
This is either the <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi></math> converted to a simple name or the index converted to a name (where possible) if it is an indexed-accessed expression.</p>
</dd>
</dl>
</div>
<h5 id="property-acessors-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p>The parameterization is part of the property access in case of generic methods.
For generic functions, a parameterized function call is introduced (cf. <a href="#_function-calls">Function Calls</a>).
The constraints are basically similar.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-97"></a><strong>Req. IDE-97:</strong> <a href="#Req-IDE-97">Property Access and Dot Notation</a> (ver. 1)</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If dot notation is used in N4JS mode, the referenced property must exist unless receiver is a dynamic type:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>∧</mo><mo>¬</mo><mi>R</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo>→</mo><mtext>
</mtext><mspace width="3.0mm"/><mo>∃</mo><mi>m</mi><mo>∈</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>i</mi><mi>e</mi><mi>s</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></math>
</div>
</div>
</li>
<li>
<p>If dot notation is used and the referenced property exists, then the property must be accessible:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>∧</mo><mo>¬</mo><mi>R</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo>→</mo><mtext>
</mtext><mspace width="3.0mm"/><mfenced close=")" open="("><mrow><mo>∃</mo><mi>m</mi><mo>∈</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>i</mi><mi>e</mi><mi>s</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow></mfenced><mo>→</mo><mi>α</mi><mfenced close=")" open="("><mrow><mi>p</mi><mi>a</mi><mi>e</mi></mrow><mi>m</mi></mfenced></math>
</div>
</div>
</li>
<li>
<p>If dot notation is used and the referenced property exists and this property is a member with a declared <code>@This</code> type (only possible for methods or field accessors),
then the receiver must be a subtype of the declared <code>@This</code> type.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-98"></a><strong>Req. IDE-98:</strong> <a href="#Req-IDE-98">Index Access</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>An index access expression is valid iff one of the following cases applies:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>the receiver is of a dynamic type. In this case, the index may be any expression (need not be a compile-time expression).</p>
</li>
<li>
<p>the receiver is an immediate instance of <code>Object</code>, i.e. it is a subtype of <code>Object</code> and its super types but <strong>not</strong> of any other type including <code>~Object</code> and <code>~~Object</code>.</p>
</li>
<li>
<p>the receiver is of type Array, ArgumentType, string, or String (including their subtypes) <strong>and</strong> the index is an expression of type <code>number</code>.</p>
</li>
<li>
<p>the index expression is a compile-time expression</p>
<div class="ulist">
<ul>
<li>
<p><strong>and</strong> the receiver type defines a member with a name equal to the string representation of the index expression&#8217;s compile-time value<br></p>
</li>
<li>
<p><strong>and</strong> the receiver is not an enum.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="paragraph">
<p>Although index access is very limited, it is still possible to use immediate instances of <code>Object</code> in terms of a map (but this applies only to index access, not the dot notation):</p>
</div>
<div class="exampleblock">
<div class="title">Example 85. Object as Map</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var map: Object = new Object();
map["Kant"] = "Imperative";
map["Hegel"] = "Dialectic";
map.spinoza = "Am I?";  // error: Couldn't resolve reference to IdentifiableElement 'spinoza'.</code></pre>
</div>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-99"></a><strong>Req. IDE-99:</strong> <a href="#Req-IDE-99">Parameterized Property Access</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a parameterized property access expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>a</mi><mi>e</mi></math>, the following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The receiver or target must be a function or method:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mstyle mathvariant="monospace"><mtext>Function</mtext></mstyle></math></p>
</li>
<li>
<p>The number of type arguments must match the number of type parameters of the generic function or method:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>|</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>A</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mo>=</mo><mo>|</mo><mi>p</mi><mi>a</mi><mi>e</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>V</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo></math></p>
</li>
<li>
<p>The type arguments of a parameterized property access expression must be subtypes of the boundaries of the parameters of the called generic method.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Also see constraints on read (<a href="#Req-IDE-93">[Req-IDE-93]</a>) and write (<a href="#Req-IDE-121">[Req-IDE-121]</a>) access.</p>
</div>
</div>
</div>
<h5 id="type-inference-5" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.1, p.p.67ff)</a>]</p>
</div>
<div class="paragraph">
<p>We define the following type inferencing rules for property accessors:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The type of an indexed-access expression <em>p</em> is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mo>¬</mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>d</mi><mi>y</mi><mi>n</mi><mo>∨</mo><mi>p</mi><mo>.</mo><mi>i</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>x</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mfenced close="]" open="["><mrow><mi>n</mi><mi>u</mi><mi>m</mi><mi>b</mi><mi>e</mi><mi>r</mi></mrow></mfenced><mspace width="3.0mm"/><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>Array</mtext></mstyle><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>T</mtext></mstyle><mo>&gt;</mo></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow><mi>e</mi><mi>l</mi><mi>s</mi><mi>e</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
<li>
<p>The type of a property access expression is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mi>Γ</mi><mo>←</mo><mi>θ</mi><mfenced close=")" open="("><mi>R</mi></mfenced><mo>⊢</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mi>R</mi><mspace width="3.0mm"/><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>p</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>:</mi><mi>T</mi></mrow><mrow><mstyle mathvariant="monospace"><mtext>PropertyAccessExpression</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
<li>
<p>The type of a parameterized access expression <em>p</em> is inferred as follows:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mo>∃</mo><mi>m</mi><mo>∈</mo><mi>p</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mi>:</mi><mi>m</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo>=</mo><mi>p</mi><mo>.</mo><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi><mspace width="3.0mm"/><mi>Γ</mi><mo>⊢</mo><mi>m</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mi>:</mi><mi>T</mi></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>p</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_new-expression"><a class="anchor" href="#_new-expression"></a><a class="link" href="#_new-expression">8.1.8. New Expression</a></h4>
<div class="paragraph">
<p>cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.2, p.p.68)</a>]</p>
</div>
<h5 id="new-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">NewExpression: 'new' callee=MemberExpression&lt;Yield&gt; (-&gt; TypeArguments)?
        (=&gt; withArgs?='(' Arguments&lt;Yield&gt;? ')' )?</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">import Address from "my/Address";

var a = new Address();
// a.type := my/Address

class C&lt;T&gt; {
    constructor(param: T) {}
}
var c = new C&lt;string&gt;("hello");</code></pre>
</div>
</div>
<h5 id="new-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-100"></a><strong>Req. IDE-100:</strong> <a href="#Req-IDE-100">New expression</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mi>e</mi></math> be a new expression, with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>Γ</mi><mo>⊢</mo><mi>n</mi><mi>e</mi><mo>.</mo><mi>c</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>e</mi><mi>e</mi><mi>:</mi><mi>C</mi></math>.
The following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a id="new-expression-1"></a> The callee must be a constructor type: <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi><mo>&lt;</mo><mi>:</mi><mstyle mathvariant="monospace"><mtext>constructor</mtext></mstyle><mfenced close="}" open="{"><mi>?</mi></mfenced></math>  or a constructable type.</p>
</li>
<li>
<p><a id="new-expression-2"></a> Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> be the type argument of <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi></math>, that is <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi><mo>=</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>u</mi><mi>c</mi><mi>t</mi><mi>o</mi><mi>r</mi><mfenced close="}" open="{"><mi>O</mi></mfenced></math>. In that case,</p>
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> must not be an interface or enum: <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mi>C</mi></mfenced><mo>∉</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>Interface</mtext></mstyle><mstyle mathvariant="monospace"><mtext>Enum</mtext></mstyle></mfenced></math></p>
</li>
<li>
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> must not contain any wildcards.</p>
</li>
<li>
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi></math> must not be a type variable.</p>
</li>
</ol>
</div>
</li>
<li>
<p><a id="new-expression-3"></a> If <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi></math> is not a constructor type, it must be a constructable type, that is one of the following:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfenced close="}" open="{"><mtable><mtr><mtd><mstyle mathvariant="monospace"><mtext>Object, Function, String, Boolean,</mtext></mstyle></mtd></mtr><mtr><mtd><mstyle mathvariant="monospace"><mtext>Number, Array, Date, RegExp, Error</mtext></mstyle></mtd></mtr></mtable></mfenced></math>
</div>
</div>
<div class="paragraph">
<p>In particular, it must not refer to a primitive type or a defined
functions (i.e., subtypes of <code>Function</code>) cannot be used in new-expressions in
N4JS.</p>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="paragraph">
<p>Remarks:</p>
</div>
<div class="paragraph">
<p>to <a href="#new-expression-1">1</a> The type of an abstract class <code>A</code> is <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mfenced close="}" open="{"><mi>A</mi></mfenced></math>.
Or in other words: Only instantiable classes have an inferred type of <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>c</mi><mi>o</mi><mi>n</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>u</mi><mi>c</mi><mi>t</mi><mi>o</mi><mi>r</mi><mfenced close="}" open="{"><mrow><mo>.</mo><mspace width="1.0mm"/><mo>.</mo><mspace width="1.0mm"/><mo>.</mo><mspace width="1.0mm"/></mrow></mfenced></math>.</p>
</div>
<div class="paragraph">
<p>to <a href="#new-expression-2">2</a> Even though it is possible to use the constructor type of an abstract class – concrete subclasses with override compatible constructor signature will be subclasses of this constructor.</p>
</div>
<div class="paragraph">
<p>to <a href="#new-expression-3">3</a> It is not possible to refer to union or intersection at that location. So this is not explicitly denied here since it is not possible anyway.</p>
</div>
<div class="exampleblock">
<div class="title">Example 86. Abstract classes and construction</div>
<div class="content">
<div class="paragraph">
<p>The following examples demonstrates the usage of abstract classes and constructor types, to make the first two constraints more clearer:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">/* XPECT_SETUP org.eclipse.n4js.spec.tests.N4JSSpecTest END_SETUP */

abstract class A {}
class B extends A {}

// XPECT errors --&gt; "Cannot instantiate abstract class A." at "A"
var x = new A();
// XPECT noerrors --&gt;
var y = new B();

function foo(ctor : constructor{A}) {
    // XPECT noerrors --&gt;
    return new ctor();
}

// XPECT errors --&gt; "type{A} is not a subtype of constructor{A}." at "A"
foo(A);
// XPECT noerrors --&gt;
foo(B);</code></pre>
</div>
</div>
</div>
</div>
<h5 id="type-inference-6" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of a new expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mi>e</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>n</mi><mi>e</mi><mo>.</mo><mi>c</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>e</mi><mi>e</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>constructor</mtext><mtext>C</mtext></mstyle></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>n</mi><mi>e</mi><mi>:</mi><mi>C</mi></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>For classes, constructors are described in <a href="types.html#_constructor-and-classifier-type">Constructor and Classifier Type</a>.</p>
</div>
<div class="paragraph">
<p>In N4JS it is not allowed to call new on a plain function.
For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">function foo() {}
var x = new foo();</code></pre>
</div>
</div>
<div class="paragraph">
<p>will issue an error.</p>
</div>
</div>
<div class="sect3">
<h4 id="_function-expression-2"><a class="anchor" href="#_function-expression-2"></a><a class="link" href="#_function-expression-2">8.1.9. Function Expression</a></h4>
<div class="paragraph">
<p>See <a href="functions.html#_functions">Functions</a> for details.</p>
</div>
</div>
<div class="sect3">
<h4 id="_function-calls"><a class="anchor" href="#_function-calls"></a><a class="link" href="#_function-calls">8.1.10. Function Calls</a></h4>
<div class="paragraph">
<p>In N4JS, a function call [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.3)</a>] is similar to a method call.
Additionally to the ECMAScript’s CallExpression, a ParameterizedCallExpression is introduced to allow type arguments passed to plain functions.</p>
</div>
<h5 id="_syntax-12" class="discrete">Syntax</h5>
<div class="literalblock">
<div class="content">
<pre>[[function-calls-syntax]]</pre>
</div>
</div>
<div class="paragraph">
<p>Similar to [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.2.3, p.p.68ff)</a>], a function call is defined as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">CallExpression &lt;Yield&gt;:
    target=IdentifierRef&lt;Yield&gt;
    ArgumentsWithParentheses&lt;Yield&gt;
;

ParameterizedCallExpression &lt;Yield&gt;:
    TypeArguments
    target=IdentifierRef&lt;Yield&gt;
    ArgumentsWithParentheses&lt;Yield&gt;
;

fragment ArgumentsWithParentheses &lt;Yield&gt;*:
    '(' Arguments&lt;Yield&gt;? ')'
;

fragment Arguments &lt;Yield&gt;*:
    arguments+=AssignmentExpression&lt;In=true,Yield&gt; (',' arguments+=AssignmentExpression&lt;In=true,Yield&gt;)* (',' spread?='...' arguments+=AssignmentExpression&lt;In=true,Yield&gt;)?
    | spread?='...' arguments+=AssignmentExpression&lt;In=true,Yield&gt;
;</code></pre>
</div>
</div>
<h5 id="function-calls-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-101"></a><strong>Req. IDE-101:</strong> <a href="#Req-IDE-101">Function Call Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given call expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi></math> bound to a method or function declaration <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If less arguments are provided than formal parameters were declared, the missing formal parameters must have been declared optional:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>|</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mo>&lt;</mo><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>→</mo><mo>∀</mo><mo>|</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mo>&lt;</mo><mi>i</mi><mo>≤</mo><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mi>:</mi><msub><mi>F</mi><mi>p</mi></msub><mi>a</mi><mi>r</mi><msub><mi>s</mi><mi>i</mi></msub><mo>.</mo><mi>o</mi><mi>p</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>a</mi><mi>l</mi></math></p>
</li>
<li>
<p>If more arguments are provided than formal parameters were declared, the last formal parameter must have been declared variadic:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>|</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mo>&gt;</mo><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>→</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><msub><mi>s</mi><mrow><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>-</mo><mn>1</mn></mrow></msub><mo>.</mo><mi>v</mi><mi>a</mi><mi>r</mi><mi>i</mi><mi>a</mi><mi>d</mi><mi>i</mi><mi>c</mi></math></p>
</li>
<li>
<p>Types of provided arguments must be subtypes of the formal parameter types:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∀</mo><mn>0</mn><mo>&lt;</mo><mi>i</mi><mo>&lt;</mo><mi>m</mi><mi>i</mi><mi>n</mi><mfenced close=")" open="("><mrow><mo>|</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo></mrow><mrow><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo></mrow></mfenced><mi>:</mi><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><msub><mi>s</mi><mi>i</mi></msub><mo>&lt;</mo><mi>:</mi><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><msub><mi>s</mi><mi>i</mi></msub></math></p>
</li>
<li>
<p>If more arguments are provided than formal parameters were declared, the type of the exceeding arguments must be a subtype of the last (variadic) formal parameter type:<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mo>∀</mo><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>&lt;</mo><mi>i</mi><mo>≤</mo><mo>|</mo><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><mi>s</mi><mo>|</mo><mi>:</mi><mi>f</mi><mo>.</mo><mi>a</mi><mi>r</mi><mi>g</mi><msub><mi>s</mi><mi>i</mi></msub><mo>&lt;</mo><mi>:</mi><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><msub><mi>s</mi><mrow><mo>|</mo><mi>F</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>-</mo><mn>1</mn></mrow></msub></math></p>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-102"></a><strong>Req. IDE-102:</strong> <a href="#Req-IDE-102">Parameterized Function Call Constraints</a> (ver. 1)</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The number of type arguments in a parameterized call expression must be equal to the number of type parameters of the generic function / method and the
type arguments must be subtypes of the corresponding declared upper boundaries of the type parameters of the called generic function.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Note that (for a limited time), constraints <a href="#Req-IDE-101">[Req-IDE-101]</a> and <a href="#Req-IDE-102">[Req-IDE-102]</a> are not applied if the the type of <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi></math> is <code>Function</code>.
See <a href="types.html#_function-object-type">Function-Object-Type</a>.</p>
</div>
</div>
</div>
<h5 id="type-inference-7" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>A call expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></math> is bound to a method (<a href="classifiers.html#_methods">Methods</a>) or function declaration (which may be part of a function definition
(<a href="functions.html#_function-declaration">Function Declaration</a> or specified via a function type <a href="functions.html#_function-type">Function Type</a>) <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi></math> (via evaluation of <code>MemberExpression</code>.
The type of the call is inferred from the function declaration or type <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi></math> as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mrow><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi></mrow><mi>F</mi></mfenced><mspace width="3.0mm"/><mi>F</mi><mo>.</mo><mi>r</mi><mi>e</mi><mi>t</mi><mi>u</mi><mi>r</mi><mi>n</mi><mi>T</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>A generic method invocation may be parameterized as well.
This is rarely required as the function argument types are usually inferred from the given arguments.
In some cases, for instance with pathSelectors, this is useful.
In that case, the type variable defined in the generic method declaration is explicitly bound to types by using type arguments.
See <a href="#_property-accessors">Property Accessors</a> for semantics and type inference.</p>
</div>
<div class="exampleblock">
<div class="title">Example 87. Generic Method Invocation</div>
<div class="content">
<div class="paragraph">
<p>This examples demonstrate how to explicitly
define the type argument in a method call in case it cannot be inferred
automatically.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class C {
    static &lt;T&gt; foo(p: pathSelector&lt;T&gt;): void {..}
};
C.&lt;my.Address&gt;foo("street.number");</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that in many cases, the type inferencer should be able to infer the type automatically.
For example, for a method</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">function &lt;T&gt; bar(c: T, p: pathSelector&lt;T&gt;): void {..};</code></pre>
</div>
</div>
<div class="paragraph">
<p>and a function call</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">bar(context, "some.path.selector");
[source,n4js]</code></pre>
</div>
</div>
<div class="paragraph">
<p>the type variable <code>T</code> can be automatically bound to the type of variable <code>context</code>.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_postfix-expression"><a class="anchor" href="#_postfix-expression"></a><a class="link" href="#_postfix-expression">8.1.11. Postfix Expression</a></h4>
<h5 id="postfix-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">PostfixExpression returns Expression: LeftHandSideExpression
         (=&gt;({PostfixExpression.expression=current} /* no line terminator here */ op=PostfixOperator))?
    ;
enum PostfixOperator: inc='++' | dec='--';</code></pre>
</div>
</div>
<h5 id="semantics-and-type-inference" class="discrete">Semantics and Type Inference</h5>
<div class="paragraph">
<p>The type inference and constraints for postfix operators <code>++</code> and <code>--</code>, cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.3.1, p.p.70)</a>], [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.3.1, p.p.70)</a>],
are defined similarly to their prefix variants (unary expressions), see <a href="#_unary-expression">Unary Expression</a>.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-103"></a><strong>Req. IDE-103:</strong> <a href="#Req-IDE-103">Postfix Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given postfix expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>∈</mo><mfenced close="}" open="{"><mrow><mo>+</mo><mo>+</mo></mrow><mrow><mo>-</mo><mo>-</mo></mrow></mfenced></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>T</mi></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In N4JS mode, the type <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi></math> of the expression must be a number.</p>
</li>
<li>
<p>If <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>=</mo><mi>P</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mspace width="0.278em"/><mi>p</mi><mi>a</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>∧</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mo>→</mo></math> both <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>g</mi><mi>e</mi><mi>t</mi></math> <em>p</em> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi><mi>e</mi><mi>t</mi></math> <em>p</em> must be defined.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_unary-expression"><a class="anchor" href="#_unary-expression"></a><a class="link" href="#_unary-expression">8.1.12. Unary Expression</a></h4>
<h5 id="unary-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>We define the following unary operators and expression, similar to [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.70ff)</a>]:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">UnaryExpression returns Expression:
      PostfixExpression
    | ({UnaryExpression} op=UnaryOperator expression=UnaryExpression);
enum UnaryOperator: delete | void | typeof | inc='++' | dec='--' | pos='+' | neg='-' | inv='$\sim$' | not='!';</code></pre>
</div>
</div>
<h5 id="unary-expression-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p>For semantics of the delete operator, see also [<a href="appendix_c_bibliography.html#MozillaJSRef">MozillaJSRef</a>]</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-104"></a><strong>Req. IDE-104:</strong> <a href="#Req-IDE-104">Delete Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given unary expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>delete</mtext></mstyle></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In strict mode, <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi></math> must be a reference to a property of an object literal, a member of a class type, or to a property of the global type
(i.e., the reference must be bound, and the bound target must not be a variable).</p>
</li>
<li>
<p>In N4JS mode, the referenced property or member must not be declared in the containing type and the containing type reference must be declared dynamic.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-105"></a><strong>Req. IDE-105:</strong> <a href="#Req-IDE-105">Void Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>There are no specific constraints defined for with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>void</mtext></mstyle></math></p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-106"></a><strong>Req. IDE-106:</strong> <a href="#Req-IDE-106">Typeof Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>There are no specific constraints defined for unary expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>typeof</mtext></mstyle></math>.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-107"></a><strong>Req. IDE-107:</strong> <a href="#Req-IDE-107">Increment/Decrement Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given unary expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>∈</mo><mfenced close="}" open="{"><mrow><mo>+</mo><mo>+</mo></mrow><mrow><mo>-</mo><mo>-</mo></mrow></mfenced></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>T</mi></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If mode is N4JS,  the type <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>T</mi></math> of the expression must be a number</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>UnaryExpression</mtext></mstyle><mo>⊲</mo><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</li>
<li>
<p>If <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>=</mo><mi>P</mi><mi>r</mi><mi>o</mi><mi>p</mi><mi>e</mi><mi>r</mi><mi>t</mi><mi>y</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mspace width="0.278em"/><mi>p</mi><mi>a</mi><mfenced close=")" open="("><mi>p</mi></mfenced><mo>∧</mo><mi>p</mi><mi>a</mi><mo>.</mo><mi>i</mi><mi>s</mi><mi>D</mi><mi>o</mi><mi>t</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi></math> <math xmlns="http://www.w3.org/1998/Math/MathML"><mo>→</mo></math> both <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>g</mi><mi>e</mi><mi>t</mi></math> <em>p</em> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi><mi>e</mi><mi>t</mi></math> <em>p</em> must be defined.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-108"></a><strong>Req. IDE-108:</strong> <a href="#Req-IDE-108">Unary Plus/Minus/Bitwise Not Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given unary expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>∈</mo><mfenced close="}" open="{"><mo>+</mo><mo>-</mo><mo>∼</mo></mfenced></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>T</mi></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In N4JS mode, the type T of the expression must be a number:</p>
</li>
</ul>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>UnaryExpression</mtext></mstyle><mo>⊲</mo><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-109"></a><strong>Req. IDE-109:</strong> <a href="#Req-IDE-109">Logical Not Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>There are no specific constraints defined for with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>u</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>!</mtext></mstyle></math>.</p>
</div>
</div>
</div>
<h5 id="type-inference-8" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The following operators have fixed types independent of their operand types:</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>’delete’</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>’void’</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>’typeof’</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>string</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>(’++’—’–’—’+’—’-’—’ ’)</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>’!’</mtext></mstyle><mi> </mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math></p>
</div>
</div>
<div class="sect3">
<h4 id="_multiplicative-expression"><a class="anchor" href="#_multiplicative-expression"></a><a class="link" href="#_multiplicative-expression">8.1.13. Multiplicative Expression</a></h4>
<h5 id="multiplicative-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.73ff)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">MultiplicativeExpression returns Expression: UnaryExpression
      (=&gt;({MultiplicativeExpression.lhs=current} op=MultiplicativeOperator) rhs=UnaryExpression)*;
enum MultiplicativeOperator: times='*' | div='/' | mod='%';</code></pre>
</div>
</div>
<h5 id="multiplicative-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-110"></a><strong>Req. IDE-110:</strong> <a href="#Req-IDE-110">Multiplicative Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given multiplicative expression the following constraints must hold in N4JS mode :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The types of the operands may be any type:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>MultiplicativeExpression</mtext></mstyle><mo>⊲</mo><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac><mrow/></math>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="paragraph">
<p>If a non-numeric operand is used, the result may be <code>NaN</code> which actually is a number as well.</p>
</div>
<h5 id="_type-inference-6" class="discrete">Type Inference</h5>
<div class="literalblock">
<div class="content">
<pre>[[type-inference-9]]</pre>
</div>
</div>
<div class="paragraph">
<p>The inferred type of a multiplicative expression always is number:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>MultiplicativeExpression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_additive-expression"><a class="anchor" href="#_additive-expression"></a><a class="link" href="#_additive-expression">8.1.14. Additive Expression</a></h4>
<h5 id="additive-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.75ff)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">AdditiveExpression returns Expression: MultiplicativeExpression
    (=&gt;({AdditiveExpression.lhs=current} op=AdditiveOperator) rhs=MultiplicativeExpression)*;
enum AdditiveOperator: add='+' | sub='-';</code></pre>
</div>
</div>
<h5 id="additive-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-111"></a><strong>Req. IDE-111:</strong> <a href="#Req-IDE-111">Additive Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given additive expression the following constraints must hold in N4JS mode:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The type of the operand can be any type:</p>
</li>
</ul>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>AdditiveExpression</mtext></mstyle><mi> </mi><mi>e</mi><mo>⊲</mo><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>In JavaScript it is possible to subtract two non-numerics, leading to <code>NaN</code>. Also <code>undefined</code> or <code>null</code> may be used. The real difference is what type is to be returned (string or number, see below).</p>
</div>
<div class="sect4">
<h5 id="type-inference-10"><a class="anchor" href="#type-inference-10"></a><a class="link" href="#type-inference-10">8.1.14.1. Type Inference</a></h5>
<div class="paragraph language-n4js">
<p>The type of an additive expression is usually inferred to <code>number</code>, except for addition which may lead to string as well.
The result for the addition operator is only be a number if both operands are numbers, booleans, null, or undefined.
Using <code>undefined</code> in an additive expression leads to <code>NaN</code> which actually is a number from the type system&#8217;s point of view. Additional analysis may create errors in the latter case though.</p>
</div>
<div class="paragraph">
<p>We first define two helper rules to simplify the addition operator condition:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mo>∃</mo><mi>N</mi><mi>i</mi><mi>n</mi><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number, int, boolean, null, undefined</mtext></mstyle></mfenced><mi>:</mi><mi>T</mi><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mo>=</mo><mi>N</mi></mrow><mrow><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>T</mi></mfenced></mrow></mfrac><mstyle mathvariant="monospace"><mtext>nb</mtext></mstyle></mtd></mtr><mtr><mtd><mfrac><mrow><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>T</mi></mfenced><mo>∨</mo><mi> </mi><mrow><mo>(</mo><mi>μ</mi><mfenced close=")" open="("><mi>T</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>Union</mtext></mstyle><mi> </mi><mo>∧</mo><mi> </mi><mo>∃</mo><mi> </mi><mi>E</mi><mo>∈</mo><mi>T</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>R</mi><mi>e</mi><mi>f</mi><mi>s</mi><mi>:</mi><mi>m</mi><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>E</mi></mfenced></mrow></mrow><mrow><mi>m</mi><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>T</mi></mfenced></mrow></mfrac><mstyle mathvariant="monospace"><mtext>mnb</mtext></mstyle></mtd></mtr><mtr><mtd><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mo>.</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>L</mi><mspace width="3.0mm"/><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mo>.</mo><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>R</mi><mspace width="3.0mm"/><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>L</mi></mfenced><mspace width="3.0mm"/><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>R</mi></mfenced></mrow><mrow><mi>t</mi><mi>o</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mrow><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></mrow></mfenced></mrow></mfrac><mstyle mathvariant="monospace"><mtext>toNum</mtext></mstyle></mtd></mtr><mtr><mtd><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mo>.</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>L</mi><mspace width="3.0mm"/><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mo>.</mo><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>R</mi><mspace width="3.0mm"/><mi>m</mi><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>L</mi></mfenced><mspace width="3.0mm"/><mi>m</mi><mi>n</mi><mi>b</mi><mfenced close=")" open="("><mi>R</mi></mfenced></mrow><mrow><mi>m</mi><mi>a</mi><mi>y</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mrow><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></mrow></mfenced></mrow></mfrac><mstyle mathvariant="monospace"><mtext>mayNum</mtext></mstyle></mtd></mtr></mtable></math>
</div>
</div>
<div class="paragraph">
<p>The type of an additive expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> is inferred as follows:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mfrac><mrow><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><msup><mo>=</mo><mi>'</mi></msup><msup><mo>+</mo><mi>'</mi></msup><mspace width="3.0mm"/><mo>¬</mo><mi>t</mi><mi>o</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mi>e</mi></mfenced><mspace width="3.0mm"/><mo>¬</mo><mi>m</mi><mi>a</mi><mi>y</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mi>e</mi></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>string</mtext></mstyle></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><msup><mo>=</mo><mi>'</mi></msup><msup><mo>+</mo><mi>'</mi></msup><mspace width="3.0mm"/><mo>¬</mo><mi>t</mi><mi>o</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mi>e</mi></mfenced><mspace width="3.0mm"/><mi>m</mi><mi>a</mi><mi>y</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mi>e</mi></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>:</mi><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mrow><mi>n</mi><mi>u</mi><mi>m</mi><mi>b</mi><mi>e</mi><mi>r</mi><mo>,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow></mfenced></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><msup><mo>=</mo><mi>'</mi></msup><msup><mo>+</mo><mi>'</mi></msup><mspace width="3.0mm"/><mi>t</mi><mi>o</mi><mi>N</mi><mi>u</mi><mi>m</mi><mfenced close=")" open="("><mi>e</mi></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></mtd></mtr><mtr><mtd><mfrac><mrow><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><msup><mo>≤</mo><mi>'</mi></msup><msup><mo>+</mo><mi>'</mi></msup></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
<div class="paragraph">
<p>That is, if both operands are number, int, boolean, null, or even undefined, then the 'plus' is interpreted as
mathematical addition and the result is a number. In other cases the 'plus' is interpreted as string concatenation and the result is a string. In case of union types, the result may be a union of number and string.</p>
</div>
<div class="paragraph">
<p>Adding two integers (int) leads to a number, since the result may not be represented as an (JavaScript) int anymore.</p>
</div>
<div class="exampleblock">
<div class="title">Example 88. Type of addition expression</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">1+2;            // number 3
"1"+"2";        // string "12"
"1"+2;          // string "12"
1+true;         // number 2
false+1;        // number 1
"1"+true;       // string "1true"
"1"+null;       // string "1null"
1+null;         // number 1
1+undefined;    // number NaN
"1"+undefined;  // string "1undefined"</code></pre>
</div>
</div>
</div>
</div>
<div class="openblock todo">
<div class="content">
<div class="paragraph">
<p>Support new <code>Symbol.toPrimitive</code>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_bitwise-shift-expression"><a class="anchor" href="#_bitwise-shift-expression"></a><a class="link" href="#_bitwise-shift-expression">8.1.15. Bitwise Shift Expression</a></h4>
<h5 id="bitwise-shift-expression-syntax" class="discrete">Syntax</h5>
<div class="literalblock">
<div class="content">
<pre>Cf. +[+&lt;&lt;ECMA11a,ECMA11a(p.p.76f)&gt;&gt;+]+</pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ShiftExpression returns Expression: AdditiveExpression
    (=&gt;({ShiftExpression.lhs=current} op=ShiftOperator rhs=AdditiveExpression))*
;

ShiftOperator returns ShiftOperator:
      '&gt;' '&gt;' '&gt;'? // SHR, USHR
    | '&lt;' '&lt;'  // SHL
    ;</code></pre>
</div>
</div>
<h5 id="bitwise-shift-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-112"></a><strong>Req. IDE-112:</strong> <a href="#Req-IDE-112">Bitwise Shift Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given bitwise shift expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> the following constraints must hold in N4JS mode:
* The types of the operands can be any.</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>BitwiseShiftExpression</mtext></mstyle><mi> </mi><mo>⊲</mo><mi> </mi><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>any</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
</div>
<h5 id="type-inference-11" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type returned by a bitwise shift expression is always <code>number</code>:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi> </mi><mrow><mo>(</mo><mrow><mstyle mathvariant="monospace"><mtext>Expression (’</mtext></mstyle><mo>&lt;</mo><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>’—’</mtext></mstyle><mo>&gt;</mo><mo>&gt;</mo><mstyle mathvariant="monospace"><mtext>’—’</mtext></mstyle><mo>&gt;</mo><mo>&gt;</mo><mo>&gt;</mo><mstyle mathvariant="monospace"><mtext>’)</mtext> <mtext>Expression</mtext></mstyle><mo>)</mo></mrow><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mrow></mfrac><mtext>
</mtext></math>
</div>
</div>
<div class="paragraph">
<p>A non-numeric operand is interpreted as 0, except for <code>true</code> which is interpreted as <code>1</code>; or objects implementing the symbol <code>toPrimitive</code>.</p>
</div>
</div>
<div class="sect3">
<h4 id="_relational-expression"><a class="anchor" href="#_relational-expression"></a><a class="link" href="#_relational-expression">8.1.16. Relational Expression</a></h4>
<h5 id="relational-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.77ff)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">RelationalExpression returns Expression: ShiftExpression
    (=&gt;({RelationalExpression.lhs=current} op=RelationalOperator) rhs=ShiftExpression)*;

RelationalExpressionNoIn returns Expression: ShiftExpression
    (=&gt;({RelationalExpression.lhs=current} op=RelationalOperatorNoIn) rhs=ShiftExpression)*;

enum RelationalOperator:
    lt='&lt;' | gt='&gt;' | lte='&lt;=' | gte='&gt;=' | instanceof | in;
RelationalOperatorNoIn returns RelationalOperator:
    '&lt;' | '&gt;' | '&lt;=' | '&gt;=' | 'instanceof';</code></pre>
</div>
</div>
<h5 id="relational-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-113"></a><strong>Req. IDE-113:</strong> <a href="#Req-IDE-113">Greater/Less (Equals) Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given relational expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>∈</mo><mrow><mo>{</mo><mrow><mo>&lt;</mo><mo>,</mo><mo>&gt;</mo><mo>,</mo><mo>&lt;</mo><mo>=</mo><mo>,</mo><mo>&gt;</mo><mo>=</mo><mo>}</mo></mrow></mrow></math> in N4JS mode,
the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The operands must have the same type and the type must be either a number, string, or boolean:</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi><mspace width="3.0mm"/><mi>T</mi><mo>∈</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mrow><mo>(</mo><mrow><mi>'</mi><msup><mo>&lt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&lt;</mo><msup><mo>=</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><msup><mo>&gt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&gt;</mo><msup><mo>=</mo><mi>'</mi></msup><mo>)</mo></mrow><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi></mrow></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>O</mi><mspace width="3.0mm"/><mi>O</mi><mo>∉</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced><mspace width="3.0mm"/><mi>T</mi><mo>=</mo><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mrow><mo>(</mo><mrow><mi>'</mi><msup><mo>&lt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&lt;</mo><msup><mo>=</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><msup><mo>&gt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&gt;</mo><msup><mo>=</mo><mi>'</mi></msup><mo>)</mo></mrow><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi></mrow></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi><mspace width="3.0mm"/><mi>T</mi><mo>∈</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mrow><mo>(</mo><mrow><mi>'</mi><msup><mo>&lt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&lt;</mo><msup><mo>=</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><msup><mo>&gt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&gt;</mo><msup><mo>=</mo><mi>'</mi></msup><mo>)</mo></mrow><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi></mrow></mrow></mfrac></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>O</mi><mspace width="3.0mm"/><mi>O</mi><mo>∉</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced><mspace width="3.0mm"/><mi>T</mi><mo>=</mo><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>number,string,boolean</mtext></mstyle></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mrow><mo>(</mo><mrow><mi>'</mi><msup><mo>&lt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&lt;</mo><msup><mo>=</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><msup><mo>&gt;</mo><mi>'</mi></msup><msup><mo>|</mo><mi>'</mi></msup><mo>&gt;</mo><msup><mo>=</mo><mi>'</mi></msup><mo>)</mo></mrow><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>T</mi></mrow></mrow></mfrac></math></p>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-114"></a><strong>Req. IDE-114:</strong> <a href="#Req-IDE-114">Instanceof Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given relational expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> with  <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>instanceof</mtext></mstyle></math>, the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The right operand of the instanceof operator must be a <code>Function</code> <sup class="footnote">[<a id="_footnoteref_49" class="footnote" href="appendix_c_bibliography.html#_footnote_49" title="View footnote.">49</a>]</sup></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In other words,</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’instanceof’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>type</mtext></mstyle><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>Class</mtext></mstyle></mfenced></mrow></mfrac><mrow/></math>
</div>
</div>
<div class="paragraph">
<p>is contained in the the first type rule, an object type reference <sup class="footnote">[<a id="_footnoteref_50" class="footnote" href="appendix_c_bibliography.html#_footnote_50" title="View footnote.">50</a>]</sup>
or an enum type reference.</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’instanceof’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>Function</mtext></mstyle></mrow></mfrac></mtd></mtr><mtr><mtd><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’instanceof’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>type</mtext></mstyle><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>Object</mtext></mstyle></mfenced></mrow></mfrac></mtd></mtr><mtr><mtd><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’instanceof’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>type</mtext></mstyle><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>N4Enum</mtext></mstyle></mfenced></mrow></mfrac></mtd></mtr></mtable></math>
</div>
</div>
<div class="paragraph">
<p>The type of a definition site structural classifier <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi></math> is not of type <code>C</code>.
Thus, the <code>instanceof</code> operator cannot be used for structural types.
Use-site structural typing is also not possible since <code>~</code> would be interpreted (by the parser) as a binary operator.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-115"></a><strong>Req. IDE-115:</strong> <a href="#Req-IDE-115">Operator Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given relational expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>in</mtext></mstyle></math>, the following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The right operand of the in operator must be an <code>Object</code>:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’in’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>Object</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</li>
<li>
<p>In N4JS mode, the left operand is restricted to be of type <code>string</code> or <code>number</code>:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’in’</mtext></mstyle><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mo>⊲</mo><mi> </mi><mi>l</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>string,number</mtext></mstyle></mfenced></mrow></mfrac></math>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="paragraph">
<p>A special feature of N4JS is support for interface type references in combination with the <code>instance of</code> operator.
The compiler rewrites the code to make this work.</p>
</div>
<div class="exampleblock">
<div class="title">Example 89. <code>instanceof</code> with Interface</div>
<div class="content">
<div class="paragraph">
<p>The following example demonstrates the use of the operator with an interface.
This is, of course, not working in pure ECMAScript.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">interface I {}

class A implements I {}
class B extends A {}
class C {}

function f(name: string, p: any) {
    if (p instanceof I) {
        console.log(name + " is instance of I");
    }
}

f("A", new A())
f("B", new B())
f("C", new C())</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will print out</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">A is instance of I
B is instance of I</code></pre>
</div>
</div>
</div>
</div>
<h5 id="type-inference-12" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type of a relational expression always is <code>boolean</code>;</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mfenced close=")" open="("><mrow><mstyle mathvariant="monospace"><mtext>’¡’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’¡=’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’¿’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’¿=’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’instanceof’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’in’</mtext></mstyle></mrow></mfenced><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_equality-expression"><a class="anchor" href="#_equality-expression"></a><a class="link" href="#_equality-expression">8.1.17. Equality Expression</a></h4>
<h5 id="equality-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.80ff)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">EqualityExpression returns Expression: RelationalExpression
    (=&gt;({EqualityExpression.lhs=current} op=EqualityOperator) rhs=RelationalExpression)*;

EqualityExpressionNoIn returns Expression: RelationalExpressionNoIn
    (=&gt;({EqualityExpression.lhs=current} op=EqualityOperator) rhs=RelationalExpressionNoIn)*;


enum EqualityOperator: same='===' | nsame='!==' | eq='==' | neq='!=';</code></pre>
</div>
</div>
<h5 id="equality-expression-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p>There are no hard constraints defined for equality expressions.</p>
</div>
<div class="paragraph">
<p>In N4JSmode, a warning is created if for a given expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>l</mi><mi>h</mi><mi>s</mi><mstyle mathvariant="monospace"><mtext>(’===’—’!==’)</mtext></mstyle><mi>r</mi><mi>h</mi><mi>s</mi></math>, neither <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>u</mi><mi>p</mi><mi>p</mi><mi>e</mi><mi>r</mi><mo>&lt;</mo><mi>:</mi><mi>r</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>u</mi><mi>p</mi><mi>p</mi><mi>e</mi><mi>r</mi></math> nor <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>Γ</mi><mo>⊢</mo><mi>r</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>u</mi><mi>p</mi><mi>p</mi><mi>e</mi><mi>r</mi><mo>&lt;</mo><mi>:</mi><mi>l</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>u</mi><mi>p</mi><mi>p</mi><mi>e</mi><mi>r</mi></math>
and no interface or composed type is involved as the result is constant in these cases.</p>
</div>
<div class="paragraph">
<p>Note that a warning is only created if the upper bounds do not match the described constraints.
This is necessary for wildcards. For example in</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">// with
class A{} class B extends A{}
function isFirst(ar: Array&lt;? extends A&gt;, b: B): boolean {
    return b === ar[0]
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>the type of array elements is <code>? extends A</code>.<br>
Neither <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>? extends A</mtext></mstyle><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mstyle mathvariant="monospace"><mtext>B</mtext></mstyle></math> nor <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant="monospace"><mtext>B</mtext></mstyle><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mstyle mathvariant="monospace"><mtext>? extends A</mtext></mstyle></math> is true.
This is why the upper bounds are to be used.</p>
</div>
<h5 id="type-inference-13" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The inferred type of an equality expression always is <code>boolean</code>.</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mi> </mi><mfenced close=")" open="("><mrow><mstyle mathvariant="monospace"><mtext>’==’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’!=’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’===’</mtext></mstyle><mo>|</mo><mstyle mathvariant="monospace"><mtext>’!==’</mtext></mstyle></mrow></mfenced><mi> </mi><mi>r</mi><mi>h</mi><mi>s</mi><mi> </mi><mi>:</mi><mstyle mathvariant="monospace"><mtext>boolean</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_binary-bitwise-expression"><a class="anchor" href="#_binary-bitwise-expression"></a><a class="link" href="#_binary-bitwise-expression">8.1.18. Binary Bitwise Expression</a></h4>
<h5 id="binary-bitwise-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.82ff)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">BitwiseANDExpression returns Expression: EqualityExpression
    (=&gt; ({BitwiseANDExpression.lhs=current} '&amp;') rhs=EqualityExpression)*;

BitwiseANDExpressionNoIn returns Expression: EqualityExpressionNoIn
    (=&gt; ({BitwiseANDExpression.lhs=current} '&amp;') rhs=EqualityExpressionNoIn)*;

BitwiseXORExpression returns Expression: BitwiseANDExpression
    (=&gt; ({BitwiseXORExpression.lhs=current} '^') rhs=BitwiseANDExpression)*;

BitwiseXORExpressionNoIn returns Expression: BitwiseANDExpressionNoIn
    (=&gt; ({BitwiseXORExpression.lhs=current} '^') rhs=BitwiseANDExpressionNoIn)*;

BitwiseORExpression returns Expression: BitwiseXORExpression
    (=&gt; ({BitwiseORExpression.lhs=current} '|') rhs=BitwiseXORExpression)*;

BitwiseORExpressionNoIn returns Expression: BitwiseXORExpressionNoIn
    (=&gt; ({BitwiseORExpression.lhs=current} '|') rhs=BitwiseXORExpressionNoIn)*;</code></pre>
</div>
</div>
<h5 id="binary-bitwise-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-116"></a><strong>Req. IDE-116:</strong> <a href="#Req-IDE-116">Bitwise Bitwise Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given bitwise bitwise expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> the following constraints must hold in N4JS mode:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The types of the operands must be both number.</p>
</li>
</ul>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>BitwiseBitwiseExpression</mtext></mstyle><mi> </mi><mo>⊲</mo><mi> </mi><mstyle mathvariant="monospace"><mtext>Expression</mtext></mstyle><mi>:</mi><mstyle mathvariant="monospace"><mtext>number</mtext></mstyle></mrow></mfrac></math>
</div>
</div>
</div>
</div>
<h5 id="type-inference-14" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The type returned by a binary bitwise expression is always <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mi>u</mi><mi>m</mi><mi>b</mi><mi>e</mi><mi>r</mi></math>:</p>
</div>
<div class="openblock">
<div class="content">

</div>
</div>
</div>
<div class="sect3">
<h4 id="_binary-logical-expression"><a class="anchor" href="#_binary-logical-expression"></a><a class="link" href="#_binary-logical-expression">8.1.19. Binary Logical Expression</a></h4>
<h5 id="binary-logical-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">LogicalANDExpression returns Expression: BitwiseORExpression
    (=&gt; ({LogicalANDExpression.lhs=current} '&amp;&amp;') rhs=BitwiseORExpression)*;
LogicalANDExpressionNoIn returns Expression: BitwiseORExpressionNoIn
    (=&gt; ({LogicalANDExpression.lhs=current} '&amp;&amp;') rhs=BitwiseORExpressionNoIn)*;

LogicalORExpression returns Expression: LogicalANDExpression
    (=&gt; ({LogicalORExpression.lhs=current} '||') rhs=LogicalANDExpression)*;
LogicalORExpressionNoIn returns Expression: LogicalANDExpressionNoIn
    (=&gt; ({LogicalORExpression.lhs=current} '||') rhs=LogicalANDExpressionNoIn)*;</code></pre>
</div>
</div>
<h5 id="binary-logical-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-117"></a><strong>Req. IDE-117:</strong> <a href="#Req-IDE-117">Binary Logical Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given binary logical expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>l</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>L</mi></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>r</mi><mi>h</mi><mi>s</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>R</mi></math> the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In N4JS mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>L</mi></math> must not be <code>undefined</code> or <code>null</code>.</p>
</li>
</ul>
</div>
</div>
</div>
<h5 id="type-inference-15" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The evaluation relies on ECMAScript’s abstract operation <code>ToBoolean</code> [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.p.43)</a>].
A short-circuit evaluation strategy is used so that depending on the types of the operands, different result types may be inferred.
In particular, the inferred type usually is not <code>boolean</code> ((cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.11., p.p.83ff)</a>] ).
The type inference does not take this short-circuit evaluation strategy into account, as it will affect the result in case one of the types is <code>null</code>
either or <code>undefined</code>, which is not allowed in N4JS mode.</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi><mstyle mathvariant="monospace"><mtext>’</mtext></mstyle><mi>&amp;</mi><mi>&amp;</mi><mstyle mathvariant="monospace"><mtext>’—’——’</mtext></mstyle><mi>r</mi><mi>h</mi><mi>s</mi><mi>:</mi><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>h</mi><mi>s</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>r</mi><mi>h</mi><mi>s</mi></mrow></mfenced></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_conditional-expression"><a class="anchor" href="#_conditional-expression"></a><a class="link" href="#_conditional-expression">8.1.20. Conditional Expression</a></h4>
<h5 id="conditional-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.12, p.p.84)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">ConditionalExpression returns Expression: LogicalORExpression
    (=&gt; ({ConditionalExpression.expression=current} '?') trueExpression=AssignmentExpression  ':' falseExpression=AssignmentExpression)?;

ConditionalExpressionNoIn returns Expression: LogicalORExpressionNoIn
    (=&gt; ({ConditionalExpression.expression=current} '?') trueExpression=AssignmentExpression  ':' falseExpression=AssignmentExpressionNoIn)?;</code></pre>
</div>
</div>
<h5 id="conditional-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-118"></a><strong>Req. IDE-118:</strong> <a href="#Req-IDE-118">Conditional Expression Constraints</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given conditional expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi></math> with</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>C</mi><mo>,</mo></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>t</mi><mi>r</mi><mi>u</mi><mi>e</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>T</mi><mo>,</mo></math><br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>f</mi><mi>a</mi><mi>l</mi><mi>s</mi><mi>e</mi><mo>-</mo><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>e</mi><mi>:</mi><mi>F</mi></math></p>
</div>
<div class="paragraph">
<p>the following constraints must hold:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A warning will be issued in N4JSmode if <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi></math> evaluates to a constant value.
That is to say<br>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>∈</mo><mfenced close="}" open="{"><mrow><mi>f</mi><mi>a</mi><mi>l</mi><mi>s</mi><mi>e</mi></mrow><mrow><mi>t</mi><mi>r</mi><mi>u</mi><mi>e</mi></mrow><mrow><mi>n</mi><mi>u</mi><mi>l</mi><mi>l</mi></mrow><mrow><mi>u</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>f</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>d</mi></mrow></mfenced></math> or
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi><mo>∈</mo><mfenced close="}" open="{"><mstyle mathvariant="monospace"><mtext>void</mtext></mstyle><mstyle mathvariant="monospace"><mtext>undefined</mtext></mstyle></mfenced></math>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There are no specific constraints defined for the condition.
The ECMAScript operation <code>ToBoolean</code> [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S9.2, p.p.43)</a>] is used to convert any type to boolean.</p>
</div>
</div>
</div>
<h5 id="type-inference-16" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>The inferred type of a conditional expression is the union of the true and false expression (cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.12, p.p.84)</a>]   ():</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>T</mi><mo>=</mo><mi>u</mi><mi>n</mi><mi>i</mi><mi>o</mi><mi>n</mi><mfenced close="}" open="{"><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>t</mi><mo>,</mo><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>f</mi></mrow></mfenced></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>d</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’?’</mtext></mstyle><mi>e</mi><mi>t</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’:’</mtext></mstyle><mi>e</mi><mi>f</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 90. Type of Conditional Expressions</div>
<div class="content">
<div class="paragraph">
<p>Given the following declarations:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A{}       class B extends A{}
class C{}       class D extends A{}
class G&lt;T&gt; { field: T; }

var ga: G&lt;A&gt;, gb: G&lt;B&gt;;
    a: A, b: B, c: C, d: D;
var boolean cond;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then the type of the following conditional expression is inferred as noted in the comments:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">cond ? a : a;                           // A
cond ? a : b;                           // union{A,B}
cond ? a : c;                           // union{A,C}
cond ? b : d;                           // union{B,D}
cond ? (cond ? a : b) : (cond ? c : d); // union{A,B,C,D}
cond ? (cond ? a : b) : (cond ? b : d); // union{A,B,D}
cond ? ga : gb;                         // union{G&lt;A&gt;,G&lt;B&gt;}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_assignment-expression"><a class="anchor" href="#_assignment-expression"></a><a class="link" href="#_assignment-expression">8.1.21. Assignment Expression</a></h4>
<h5 id="assignment-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">AssignmentExpression &lt;In, Yield&gt;:
    lhs=Expression op=AssignmentOperator rhs=AssignmentExpression&lt;In,Yield&gt;
;
AssignmentOperator:
      '='
    | '*=' | '/=' | '%=' | '+=' | '-='
    | '&lt;&lt;=' | '&gt;&gt;=' | '&gt;&gt;&gt;='
    | '&amp;=' | '^=' | '|='
;</code></pre>
</div>
</div>
<h5 id="assignment-expression-semantics" class="discrete">Semantics</h5>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-119"></a><strong>Req. IDE-119:</strong> <a href="#Req-IDE-119">Simple Assignment</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given assignment <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi></math> with</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mo>.</mo><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>’=’</mtext></mstyle></math></p>
</div>
<div class="paragraph">
<p>the following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>[</mo><mspace width="-0.167em"/><mrow><mo>[</mo></mrow></mrow><mrow><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mo>.</mo><mi>l</mi><mi>h</mi><mi>s</mi></mrow><mrow><mrow><mo>]</mo></mrow><mspace width="-0.167em"/><mo>]</mo></mrow><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mrow><mo>[</mo><mspace width="-0.167em"/><mrow><mo>[</mo></mrow></mrow><mrow><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mo>.</mo><mi>r</mi><mi>h</mi><mi>s</mi></mrow><mrow><mrow><mo>]</mo></mrow><mspace width="-0.167em"/><mo>]</mo></mrow></math></p>
<div class="paragraph">
<p>In the following inference rule and the constraint, ’@’ is to be replaced with the right part of one of the assignment operators listed above, that is,</p>
</div>
<div class="openblock">
<div class="content">

</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-120"></a><strong>Req. IDE-120:</strong> <a href="#Req-IDE-120">Compound Assignment</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given assignment <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mi> </mi><mi>o</mi><mi>p</mi><mi> </mi><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi></math>, with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>o</mi><mi>p</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>’@=’</mtext></mstyle></math> but not <code>+=</code>, both, left and right must be subtypes of <code>number</code>.<br>
For operator <code>+=</code>,</p>
</div>
<div class="ulist">
<ul>
<li>
<p>if the left-hand side is a <code>number</code>, then <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’+’</mtext></mstyle><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi></math> must return a number as well.
The right-hand side must, in fact, be a <code>number</code> (and not a <code>boolean</code>) here in order to avoid unexpected results.</p>
</li>
<li>
<p>if the left-hand side is a <code>string</code>, then <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mstyle mathvariant="monospace"><mtext>’+’</mtext></mstyle><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi></math> must return a string as well.
That means that the right-hand side can be of <code>any</code> type.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The expected type for the left-hand side is <code>union{number,string}</code>.</p>
</div>
<div class="paragraph">
<p>The basic idea behind these constraints is that the type of the left-hand side is not to be changed by the compound assignment.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-121"></a><strong>Req. IDE-121:</strong> <a href="#Req-IDE-121">Write Acccess</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For a given assignment expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi></math>, the left-hand side must be writeable or a final data field and the assignment must be in the constructor.
Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>v</mi></math> be the bound variable (or field) with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi><mi>i</mi><mi>n</mi><mi>d</mi><mfenced close=")" open="("><mrow><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi></mrow><mi>v</mi></mfenced></math></p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mi>v</mi><mo>.</mo><mi>w</mi><mi>r</mi><mi>i</mi><mi>t</mi><mi>e</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi><mo>∨</mo><mi>v</mi><mo>.</mo><mi>f</mi><mi>i</mi><mi>n</mi><mi>a</mi><mi>l</mi><mo>∧</mo><mspace width="3.0mm"/><mspace width="2.0em"/><mi>v</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>null</mtext></mstyle></mtd></mtr><mtr><mtd><mspace width="3.0mm"/><mspace width="2.0em"/><mo>∧</mo><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>=</mo><mi>v</mi><mo>.</mo><mi>o</mi><mi>w</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>u</mi><mi>c</mi><mi>t</mi><mi>o</mi><mi>r</mi></mtd></mtr><mtr><mtd><mspace width="3.0mm"/><mspace width="2.0em"/><mo>∧</mo><mi>μ</mi><mfenced close=")" open="("><mrow><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyAccess</mtext></mstyle></mtd></mtr><mtr><mtd><mspace width="3.0mm"/><mspace width="4.0em"/><mo>∧</mo><mi>a</mi><mi>s</mi><mi>s</mi><mi>i</mi><mi>g</mi><mi>n</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>"this"</mtext></mstyle></mtd></mtr></mtable></math>
</div>
</div>
<div class="paragraph">
<p>The value of writeable is true for setters and usually for variables and data fields.
Assignability of variables and data fields can be restricted via <code>const</code> or the <code>@Final</code> annotation.
See <a href="classifiers.html#_assignment-modifiers">Assignment Modifiers</a>(data fields) and <a href="statements.html#_const">Const</a> (const variables) for details.</p>
</div>
<div class="paragraph">
<p>Also see <a href="#Req-IDE-93">[Req-IDE-93]</a> for read access constraint.</p>
</div>
<div class="paragraph">
<p>The left-hand side of an assignment expression may be an array or object literal and the assignment expression is then treated as a destructuring assignment.
See <a href="extended_fetaures.html#_array-and-object-destructuring">Array and Object Destructuring</a> for details.</p>
</div>
</div>
</div>
<h5 id="type-inference-17" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>Similarly to [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.1, p.p.84ff)</a>], we define type inference for simple assignment (<code>=</code>) and compound assignment (<code>op=</code>) individually.</p>
</div>
<div class="paragraph">
<p>The type of the assignment is simply the type of the right-hand side:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’=’</mtext></mstyle><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>Compound assignments are reduced to the former by splitting an operator <code>@=</code>, in which <code>@</code> is a simple operator,
into a simple operator expression with operator <code>@</code> and a simple assignment <code>=</code>.
Since the type of the latter is the right-hand side, we can define:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’@’</mtext></mstyle><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>l</mi><mi>e</mi><mi>f</mi><mi>t</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>’@=’</mtext></mstyle><mi>r</mi><mi>i</mi><mi>g</mi><mi>h</mi><mi>t</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_comma-expression"><a class="anchor" href="#_comma-expression"></a><a class="link" href="#_comma-expression">8.1.22. Comma Expression</a></h4>
<h5 id="comma-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.14, p.p.85)</a>]</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">CommaExpression &lt;In, Yield&gt;:
    exprs+=AssignmentExpression&lt;In,Yield&gt; ',' exprs+=AssignmentExpression&lt;In,Yield&gt;
    (','    exprs+=AssignmentExpression&lt;In,Yield&gt;)*
;</code></pre>
</div>
</div>
<h5 id="comma-expression-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p>All expressions will be evaluated even though only the value of the last expression will be the result.</p>
</div>
<div class="exampleblock">
<div class="title">Example 91. Comma Expression</div>
<div class="content">
<div class="paragraph">
<p>Assignment expressions preceed comma expressions:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">var b: boolean;
b = (12, 34, true); // ok, b=true
b =  12, 34, true ; // error, b=12 is invalid</code></pre>
</div>
</div>
</div>
</div>
<h5 id="type-inference-18" class="discrete">Type Inference</h5>
<div class="paragraph">
<p>Cf. [<a href="appendix_c_bibliography.html#ECMA11a">ECMA11a(p.S11.14, p.p.85)</a>]</p>
</div>
<div class="paragraph">
<p>The type of a comma expression <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></math> is inferred to the last expression:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>n</mi><mo>=</mo><mo>|</mo><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>s</mi><mo>|</mo><mo>,</mo><mi>Γ</mi><mo>⊢</mo><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><msub><mi>s</mi><mi>n</mi></msub><mi>:</mi><mi>T</mi></mrow><mrow><mi>Γ</mi><mo>⊢</mo><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
</div>
</div>
<div class="sect2 language-n4js">
<h3 id="_ecmascript-6-expressions"><a class="anchor" href="#_ecmascript-6-expressions"></a><a class="link" href="#_ecmascript-6-expressions">8.2. ECMAScript 6 Expressions</a></h3>
<div class="sect3">
<h4 id="_the-super-keyword"><a class="anchor" href="#_the-super-keyword"></a><a class="link" href="#_the-super-keyword">8.2.1. The super Keyword</a></h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">SuperLiteral: {SuperLiteral} 'super';</code></pre>
</div>
</div>
<div class="paragraph">
<p>Apart from the use of keyword <code>super</code> in wildcards of type expressions (cf. <a href="types.html#_type-expressions">Type Expressions</a>),
there are two use cases for keyword <code>super</code>: super member access and super constructor calls.</p>
</div>
<div class="exampleblock">
<div class="title">Example 92. Super Keyword</div>
<div class="content">
<div class="paragraph">
<p>Two use cases for keyword super:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class B extends A {
    constructor() {
        // super call
        super();
    }
    @Override
    m();: void {
        // super member access
        super.m();
    }
}</code></pre>
</div>
</div>
</div>
</div>
<h5 id="super-keyword-semantics" class="discrete">Semantics</h5>
<div class="paragraph">
<p><code>super</code> can be used to access the supertype’s constructor, methods, getters and setters.
The supertype is defined lexically, which is different from how <code>this</code> works.<sup class="footnote">[<a id="_footnoteref_51" class="footnote" href="appendix_c_bibliography.html#_footnote_51" title="View footnote.">51</a>]</sup></p>
</div>
<div class="paragraph">
<p>Note that in [<a href="appendix_c_bibliography.html#ECMA15a">ECMA15a</a>] Chapter 12.3.5 <code>The Super Keyword</code>, <code>super</code> is defined as a keyword but the syntax and semantics are defined in conjunction of member access.</p>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-122"></a><strong>Req. IDE-122:</strong> <a href="#Req-IDE-122">Type of Super is Always Nominal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>The type referenced with the super literal is always nominal.
This is a consequence of references to types in extend clauses to be nominal.</p>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>Γ</mi><mo>⊢</mo><mstyle mathvariant="monospace"><mtext>super</mtext></mstyle><mi>:</mi><mi>T</mi><mo>∧</mo><mi>T</mi><mo>.</mo><mi>t</mi><mi>y</mi><mi>p</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>S</mi><mi>t</mi><mi>r</mi><mi>a</mi><mi>t</mi><mi>e</mi><mi>g</mi><mi>y</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>nominal</mtext></mstyle></math></p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-123"></a><strong>Req. IDE-123:</strong> <a href="#Req-IDE-123">Access Super Constructor with Super Literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>If the super literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi></math> is used to access the super constructor of a class, all of the following constraints must hold:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The super constructor access must be a call expression:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>μ</mi><mfenced close=")" open="("><mrow><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>CallExpression</mtext></mstyle><mo>∧</mo><mi>c</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>=</mo><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi></math>
</div>
</div>
</li>
<li>
<p>The super constructor call must be the expression of an expression statement <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi></math>:</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>=</mo><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>∧</mo><mi>μ</mi><mfenced close=")" open="("><mrow><mi>c</mi><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>ExpressionStatement</mtext></mstyle></math>
</div>
</div>
</li>
<li>
<p>The containing statement <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi><mi>t</mi><mi>m</mi><mi>t</mi><mi>E</mi><mi>x</mi><mi>p</mi><mi>r</mi></math> must be directly contained in a constructor body:</p>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>μ</mi><mfenced close=")" open="("><mrow><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>Constructor</mtext></mstyle><mo>)</mo></mrow></math>
<math xmlns="http://www.w3.org/1998/Math/MathML"><mspace width="3.0mm"/><mo>∧</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>=</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo>.</mo><mi>b</mi><mi>o</mi><mi>d</mi><mi>y</mi></math></p>
</div>
</li>
<li>
<p>There must be no access to and not return statement before the containing statement <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi></math>.</p>
<div class="paragraph">
<p>Let <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi><mi>i</mi></math> be the index of <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi></math> in the constructor body:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>.</mo><mi>s</mi><mi>t</mi><mi>m</mi><mi>t</mi><msub><mi>s</mi><mrow><mi>s</mi><mi>i</mi></mrow></msub><mo>=</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi></math>
</div>
</div>
<div class="paragraph">
<p>Then, the following constraint must hold: <sup class="footnote">[<a id="_footnoteref_52" class="footnote" href="appendix_c_bibliography.html#_footnote_52" title="View footnote.">52</a>]</sup></p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mspace width="3.0mm"/><mo>∀</mo><mi>i</mi><mo>&lt;</mo><mi>s</mi><mi>i</mi><mi>:</mi><mo>∄</mo><mi>e</mi><mi>l</mi><mi>e</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><msup><mo>∈</mo><mo>*</mo></msup><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi>S</mi><mi>t</mi><mi>m</mi><mi>t</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>.</mo><mi>s</mi><mi>t</mi><mi>m</mi><mi>t</mi><msub><mi>s</mi><mi>i</mi></msub><mi>:</mi><mtext>
</mtext><mspace width="3.0mm"/><mspace width="3.0em"/><mi>μ</mi><mfenced close=")" open="("><mi>i</mi></mfenced><mo>∈</mo><mstyle mathvariant="monospace"><mtext>ThisLiteral, ReturnStatement</mtext></mstyle></math>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>Further constraints with regard to super constructor calls are described in <a href="types.html#_constructor-and-classifier-type">Constructor and Classifier Type</a>.</p>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-124"></a><strong>Req. IDE-124:</strong> <a href="#Req-IDE-124">Access Super Member with Super Literal</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>If the super literal <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>s</mi></math> is used to access a member of the super class, all of the following constraints must hold, with <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>c</mi><mo>=</mo><mi>s</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>e</mi><mi>r</mi></math></p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The super literal must be the receiver of a method call (cf. remarks below):</p>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable><mtr><mtd><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mi>c</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>CallExpression</mtext></mstyle></mtd></mtr><mtr><mtd><mo>∧</mo><mspace width="3.0mm"/><mi>c</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>PropertyAccessExpression</mtext></mstyle></mtd></mtr><mtr><mtd><mo>∧</mo><mspace width="3.0mm"/><mi>c</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>.</mo><mi>t</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi><mi>t</mi><mo>=</mo><mi>s</mi></mtd></mtr></mtable></math>
</div>
</div>
</li>
<li>
<p>The super literal is used in a method or field accessor of a class:</p>
</li>
</ol>
</div>
<div class="paragraph">
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mrow><mi>s</mi><mo>.</mo><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>C</mi><mi>l</mi><mi>a</mi><mi>s</mi><mi>s</mi></mrow></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>Class</mtext></mstyle></math>
3.  The super literal must not be used in a nested function expression:</p>
</div>
<div class="paragraph">
<p>+
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>μ</mi><mfenced close=")" open="("><mrow><mi>s</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>F</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></mrow></mfenced><mo>=</mo><mi>s</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>M</mi><mi>e</mi><mi>t</mi><mi>h</mi><mi>o</mi><mi>d</mi><mi>O</mi><mi>r</mi><mi>F</mi><mi>i</mi><mi>e</mi><mi>l</mi><mi>d</mi><mi>A</mi><mi>c</mi><mi>c</mi><mi>e</mi><mi>s</mi><mi>s</mi><mi>o</mi><mi>r</mi></math>
4.  If the return type of the method access via super is this, the actually bound this type will be the type of the calling class (and not of the class defining the method).</p>
</div>
<div class="paragraph">
<p>+</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow><mi>s</mi><mo>.</mo><mi>c</mi><mi>o</mi><mi>n</mi><mi>t</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>C</mi><mi>l</mi><mi>a</mi><mi>s</mi><mi>s</mi><mo>=</mo><mi>T</mi><mspace width="3.0mm"/><mi>μ</mi><mfenced close=")" open="("><mi>m</mi></mfenced><mo>=</mo><mstyle mathvariant="monospace"><mtext>Method</mtext></mstyle><mspace width="3.0mm"/><mi>m</mi><mo>.</mo><mi>r</mi><mi>e</mi><mi>t</mi><mi>u</mi><mi>r</mi><mi>n</mi><mi>T</mi><mi>y</mi><mi>p</mi><mi>e</mi><mo>=</mo><mstyle mathvariant="monospace"><mtext>this</mtext></mstyle></mrow><mrow><mstyle mathvariant="monospace"><mtext>function():T</mtext></mstyle><mspace width="1.0mm"/><mo>&lt;</mo><mstyle mathvariant="monospace"><mtext>:</mtext></mstyle><mspace width="1.0mm"/><mi>s</mi><mo>.</mo><mi>m</mi></mrow></mfrac></math>
</div>
</div>
</div>
</div>
<div class="openblock requirement">
<div class="content">
<div class="paragraph">
<p><a id="Req-IDE-125"></a><strong>Req. IDE-125:</strong> <a href="#Req-IDE-125">Super Literal Usage</a> (ver. 1)</p>
</div>
<div class="paragraph">
<p>For super literals, either <a href="#Req-IDE-123">[Req-IDE-123]</a> or <a href="#Req-IDE-124">[Req-IDE-124]</a> must hold, no other usage
is allowed.</p>
</div>
<div class="paragraph">
<p>Consequences:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Since fields cannot be overridden (except for changing the access modifier), it is not possible nor allowed to access a field via <code>super</code>.</p>
</li>
<li>
<p>Super literals must not be used with index access (e.g., <code>super["foo"]</code>)</p>
</li>
<li>
<p>It is not possible to chain super keywords. That is, it is not possible to call <code>super.super.m()</code>.</p>
</li>
<li>
<p>It is not allowed to use the super literal in interfaces or non-methods/accessors.</p>
</li>
<li>
<p>Super cannot be used to call an overridden method of an implemented method from the overriding method in the implementing class.</p>
</li>
<li>
<p>In order to be able to access a super method of a method <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>M</mi></math> of a class <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi></math>, exactly one non-abstract super method <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>M</mi><mi>'</mi></msup></math> in a super class <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>S</mi></math> of <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>C</mi></math> must exist.
This is assured by the standard rules for binding identifiers.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If super is used to access a super member, the receiver type is not changed.
This is important in particular for static methods as demonstrated in the following example:</p>
</div>
<div class="exampleblock">
<div class="title">Example 93. Super Call in Static Methods</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">class A {
    static foo(): void { console.log("A") }
    static bar(): void {
        this.foo();
    }
}

class B extends A {

    @Override
    static foo(): void { console.log("B") }
    @Override
    static bar(): void {
        A.bar();        <i class="conum" data-value="1"></i><b>(1)</b>
        super.bar();    <i class="conum" data-value="2"></i><b>(2)</b>
    }
}

B.bar();</code></pre>
</div>
</div>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The receiver (which is similar to the this-binding in ECMAScript) is changed to <code>A</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Using super, the receiver is preserved, i.e. <code>B</code>.</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sect2 language-n4js">
<h3 id="_ecmascript-7-expressions"><a class="anchor" href="#_ecmascript-7-expressions"></a><a class="link" href="#_ecmascript-7-expressions">8.3. ECMAScript 7 Expressions</a></h3>
<div class="sect3">
<h4 id="_await-expression"><a class="anchor" href="#_await-expression"></a><a class="link" href="#_await-expression">8.3.1. Await Expression</a></h4>
<div class="paragraph">
<p>In N4JS, <code>await</code> is implemented as a unary operator with the same precedence as <code>yield</code> in ECMAScript 6.</p>
</div>
<div class="paragraph">
<p>Constraints governing the use of <code>await</code> are given together with those for <code>async</code> in <a href="functions.html#_asynchronous-functions">Asynchronous Functions</a>.</p>
</div>
</div>
</div>
<div class="sect2 language-n4js">
<h3 id="_n4js-specific-expressions"><a class="anchor" href="#_n4js-specific-expressions"></a><a class="link" href="#_n4js-specific-expressions">8.4. N4JS Specific Expressions</a></h3>
<div class="sect3">
<h4 id="_class-expression"><a class="anchor" href="#_class-expression"></a><a class="link" href="#_class-expression">8.4.1. Class Expression</a></h4>
<div class="paragraph">
<p>A class expression in N4JS is similar to a class expression in ECMAScript 6 [<a href="appendix_c_bibliography.html#ECMA15a">ECMA15a(p.14.5)</a>].</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title=""></i>
</td>
<td class="content">
Class expressions are not part of version 0.3
</td>
</tr>
</table>
</div>
<h5 id="class-expression-syntax" class="discrete">Syntax</h5>
<div class="paragraph">
<p>See <a href="classifiers.html#_classes">Classes</a>.</p>
</div>
<h5 id="class-expression-semantics-type-inference" class="discrete">Semantics and Type Inference</h5>
<div class="paragraph">
<p>The inferred type of a class expression simply is the class type as described in <a href="types.html#_constructor-and-classifier-type">Constructor and Classifier Type</a>.</p>
</div>
</div>
<div class="sect3">
<h4 id="_cast-as-expression"><a class="anchor" href="#_cast-as-expression"></a><a class="link" href="#_cast-as-expression">8.4.2. Cast (As) Expression</a></h4>
<h5 id="cast-as-expression-syntax" class="discrete">Syntax</h5>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xtext" data-lang="xtext">CastExpression &lt;Yield&gt; returns Expression: expression=Expression 'as' targetTypeRef=TypeRefForCast;

TypeRefForCast returns StaticBaseTypeRef:
      ParameterizedTypeRef
    | ThisTypeRef
    | ConstructorTypeRef
    | ClassifierTypeRef
    | FunctionTypeExpression
    | UnionTypeExpression
    | IntersectionTypeExpression</code></pre>
</div>
</div>
<div class="sect4">
<h5 id="cast-as-expression-semantics-type-inference"><a class="anchor" href="#cast-as-expression-semantics-type-inference"></a><a class="link" href="#cast-as-expression-semantics-type-inference">8.4.2.1. Semantics and Type Inference</a></h5>
<div class="paragraph">
<p>The inferred type of the type cast expression is the target type:</p>
</div>
<div class="openblock">
<div class="content">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mfrac><mrow/><mrow><mi>Γ</mi><mo>⊢</mo><mi>e</mi><mi>x</mi><mi>p</mi><mi>r</mi><mi> </mi><mstyle mathvariant="monospace"><mtext>"as"</mtext></mstyle><mi> </mi><mi>T</mi><mi>:</mi><mi>T</mi></mrow></mfrac></math>
</div>
</div>
<div class="paragraph">
<p>The type cast returns the expression without further modifications.
Type casts are simply removed during compilation so there will be no exceptions thrown at the cast until later when accessing properties which may not be present in case of a failed cast.</p>
</div>
<div class="paragraph">
<p>An error is issued if the cast is either unnecessary or cannot succeed.
See further details in <a href="conversions_and_reflection.html#_type-cast">Type Cast</a>.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="Import_Calls"><a class="anchor" href="#Import_Calls"></a><a class="link" href="#Import_Calls">8.4.3. Import Calls</a></h4>
<div class="paragraph">
<p>Import calls as specified by the corresponding <a href="https://github.com/tc39/proposal-dynamic-import">ECMA TC39 proposal</a> are
available in N4JS. Such an import call has the form</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-n4js" data-lang="n4js">import(moduleSpecifier)</code></pre>
</div>
</div>
<div class="paragraph">
<p>and may appear in the source code wherever an expression may appear. It&#8217;s argument need not be a string literal, as is
the case with module specifiers of ordinary imports; instead, any expression that evaluates to a string at runtime is
accepted. Hence, it can be used to import from a target module that is not yet known at compile time.</p>
</div>
<div class="paragraph">
<p>A note on terminology: import calls covered in this section are sometimes referred to as "dynamic import". In N4JS
that term is already used for imports of the form <code>import * as N+ from "&#8230;&#8203;"</code>, i.e. compile-time imports that do not
require type information of the module imported from, see <a href="statements.html#Dynamic_Imports">Dynamic Imports</a>, and stems from the term "dynamic type"
(see <a href="types.html#Type_Modifiers_Dynamic">Dynamic</a>). To avoid confusion, we will usually avoid referring to import calls as a "dynamic
import".</p>
</div>
</div>
</div>
<div class="sect2 language-n4js">
<h3 id="compile-time-expressions"><a class="anchor" href="#compile-time-expressions"></a><a class="link" href="#compile-time-expressions">8.5. Compile-Time Expressions</a></h3>
<div class="paragraph">
<p>A compile-time expression is an expression that can be fully evaluated at compile time. Not all expressions introduced
in the previous sections qualify as compile-time expressions. Some forms of expressions always qualify (e.g. a string
literal is always a compile-time expression), some never (e.g. call expressions), and for some expressions the operands
must be of a certain value. The latter applies, for example, to divison: <code>5 / 0</code> is a valid ECMAScript expression (evaluating
to <code>NaN</code>) but is not a compile-time expression. So it&#8217;s the actual compile-time value of the divisor that makes the difference,
here. In any case, if an expression has operands, it is a compile-time expression only if all operands are compile-time expressions.</p>
</div>
<div class="paragraph">
<p>The value a compile-time expression evaluates to at compile-time is called <em>compile-time value</em>. So, an expression has a compile-time
value if and only if it is a compile-time expression.</p>
</div>
<div class="openblock definition">
<div class="content">
<div class="paragraph">
<p><a id="compile_time_expression"></a><strong>Definition:</strong> <a href="#compile_time_expression">Compile-Time Expression</a></p>
</div>
<div class="paragraph">
<p>The following expressions are called compile-time expressions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>undefined</code> (but not <code>NaN</code> or <code>Infinity</code>).</p>
</li>
<li>
<p>the <code>null</code> literal.</p>
</li>
<li>
<p>all boolean, numeric, and string literals.</p>
</li>
<li>
<p>template string literals, iff all embedded expressions are compile-time expressions.</p>
</li>
<li>
<p>a parenthesis expression, iff its nested expression is a compile-time expression.</p>
</li>
<li>
<p>unary expressions in case of the following operators:</p>
<div class="ulist">
<ul>
<li>
<p><code>!</code> iff the operand is a compile-time expression and evaluates to a boolean value.</p>
</li>
<li>
<p><code>+</code> iff the operand is a compile-time expression and evaluates to a numeric value.</p>
</li>
<li>
<p><code>-</code> iff the operand is a compile-time expression and evaluates to a numeric value.</p>
</li>
<li>
<p><code>void</code>.</p>
</li>
</ul>
</div>
</li>
<li>
<p>binary expressions in case of the following operators:</p>
<div class="ulist">
<ul>
<li>
<p><code>+</code> iff both operands are compile-time expressions and</p>
<div class="ulist">
<ul>
<li>
<p>both evaluate to numeric values, or</p>
</li>
<li>
<p>at least one evaluates to a string value.</p>
</li>
</ul>
</div>
</li>
<li>
<p><code>-</code>, <code>*</code> iff both operands are compile-time expressions and evaluate to numeric values.</p>
</li>
<li>
<p><code>/</code>, <code>%</code> iff both operands are compile-time expressions and evaluate to numeric values and the right-hand operand is non-zero (i.e. division by zero is disallowed in compile-time expression, because <code>NaN</code> is not a supported compile-time value).</p>
</li>
<li>
<p><code>&amp;&amp;</code>, <code>||</code> iff both operands are compile-time expressions and evaluate to boolean values.</p>
</li>
</ul>
</div>
</li>
<li>
<p>a tertiary conditional expression, iff the first operand is a compile-time expression evaluating to a boolean value B and</p>
<div class="ulist">
<ul>
<li>
<p>in case B is true, the second operand is a compile-time expression.</p>
</li>
<li>
<p>in case B is false, the third operand is a compile-time expression.</p>
</li>
</ul>
</div>
</li>
<li>
<p>an identifier reference to a const variable, iff its initializer expression is a compile-time expression.</p>
</li>
<li>
<p>a property access expression, iff it is direct (see <a href="#property-access-direct">Direct Property Access</a>) and refers to</p>
<div class="ulist">
<ul>
<li>
<p>a built-in symbol, e.g. <code>Symbol.iterator</code>,</p>
</li>
<li>
<p>a literal of a <code>@StringBased</code> enum, or</p>
</li>
<li>
<p>a const field with a compile-time initializer expression.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>In all other cases, the expression is not a compile-time expression.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>Every expression in the code may be a compile-time expression, but in most places this has no particular
effect and is simply ignored. They are of significance only in computed property names, in index access
expressions, as initializers of const variables and fields (as stated above) and when nested as an operand
inside an expression at these locations.</p>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Version 0.9<br>
Last updated 2019-08-08 13:15:33 CEST
</div>
</div>
<!-- ************* docinfo-footer *************************************************************** -->
<div class="Grid social" style="color:#d5dfea">
  <div class="Cell Cell--2-12 m-Cell--withMargin">
    <h2>Quick Links</h2>
    <ul>
      <li><a href="../downloads.html">Download</a></li>
      <li><a href="../userguides/index.html">Documentation</a></li>
      <li><a href="https://github.com/eclipse/n4js/">Source</a></li>
      <li><a href="https://github.com/eclipse/n4js/issues">Issues</a></li>
    </ul>
  </div>
  <div class="Cell Cell--2-12 m-Cell--withMargin">
    <br/><br/>
    <ul>
      <li><a href="https://www.eclipse.org/forums/index.php/f/365/">Forum</a></li>
      <li><a href="http://n4js.blogspot.de/">Blog</a></li>
      <li><a href="https://dev.eclipse.org/mailman/listinfo/n4js-dev">Mailing List</a></li>
      <li><a href="https://projects.eclipse.org/projects/technology.n4js">Eclipse Project Page</a></li>
      <li><a href="https://twitter.com/n4jsdev">Tweets by n4jsdev</a></li>
    </ul>
  </div>
  <div class="Cell Cell--2-12 m-Cell--withMargin">
    <br/><br/>
    <ul>
      <li><a href="http://www.eclipse.org/">Eclipse Home</a></li>
      <li><a href="http://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li>
      <li><a href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li>
      <li><a href="http://www.eclipse.org/legal/copyright.php">Copyright Agent</a></li>
      <li><a href="http://www.eclipse.org/legal/">Legal</a></li>
    </ul>
  </div>
  <div style="clear: both; height: 0; overflow: hidden;"></div>
</div>

<!-- ************* UI Scripts ************* -->
<script type="text/javascript" src="scripts/back-to-top.js"></script>

<script type="text/javascript" src="scripts/treeview.js"></script>
<script type="text/javascript" src="scripts/toc.js"></script>

<!-- ************* Prism.js Syntax Highlighting ************* -->
<script src="scripts/prism.js"></script>

<script type="text/javascript">
	// Add the 'toclist' id for search function
	$(".toc2 > ul").attr('id', 'toclist');
	// Generate a Search input form
	$("#toclist > li:first-of-type").before('<input type="text" id="pagesearch" onkeyup="search()" placeholder="Search for section...">');
	$("#toclist > li:first-of-type").before('<i id="clear" class="fa fa-times-circle-o"></i>');
	$("#clear").click(function(){
	    $("#pagesearch").val('');
	    search();
	    $('.toc2 > ul').treeView('collapseAll');
	});
	// intialize Treeview.js
	$(".toc2 > ul").treeView();
	// Initialize Scrollspy
</script>
<!-- ************* docinfo-footer *************************************************************** -->
</body>
</html>